Use 'git pull' in Meta/PU
[git/spearce.git] / PU
blob2a22632a82aefe6c28e072dc452bba991bae979c
1 #!/bin/sh
3 # Rebuild "pu" from topic branches.
6 git-update-index --refresh || exit
7 case "$(git-diff-index --name-status HEAD)" in
8 '') ;;
9 *) echo 2>&1 "Local modifications exist."
10 exit 1;;
11 esac
12 git checkout pu &&
13 git reset --hard master &&
14 ORIG_HEAD=`git rev-parse ORIG_HEAD` || exit
15 LF='
18 case "$#" in
20 # interactive ;-)
21 shift
22 HH=`cd .git/refs/heads && find -type f |
23 sed -e 's/^\.\///' \
24 -e '/^naster$/d' -e '/^master$/d' -e '/^maint$/d' -e '/^pu$/d'`
25 while test "$HH"
27 I=0
28 echo "0: done"
29 NHH=
30 for H in $HH
32 HSHA1=`git-rev-parse --verify $H` || continue
33 MB=`git-show-branch --merge-base pu $HSHA1`
34 case "$LF$MB$LF" in
35 *"$LF$HSHA1$LF"*) continue ;; # already merged.
36 esac
37 I=$(($I+1))
38 echo -n "$I: "
39 git-show-branch $H
40 NHH="${NHH}$H "
41 done
42 case "$I" in
44 break ;;
45 esac
46 HH=$NHH
47 echo -n "Merge which ones (0 to finish)? "
48 read ans
49 case "$ans" in
50 '' | 0)
51 break ;;
52 esac
53 I=0
54 UNUSE= USE= USED=
55 for H in $HH
57 I=$(($I+1))
58 case " $ans " in
59 *' '$I' '*)
60 USE="$USE$H "
61 USED="$USED,$H"
64 UNUSE="$UNUSE$H "
66 esac
67 done
68 USED=`expr "$USED" : ',\(.*\)'`
69 git pull -n . $USE || exit
70 # git merge -n "Merge $USED" pu $USE || exit
71 HH=$UNUSE
72 done
73 exit
75 esac
77 for H
79 # (IFS=",$IFS"; git merge -n "Merge $H" pu $H) || exit
80 (IFS=",$IFS"; git pull -n . $H) || exit
81 done
83 (IFS=",$IFS"; git show-branch master $* pu `git rev-parse --short $ORIG_HEAD`)