X-Git-Url: https://git.octo.it/?a=blobdiff_plain;f=PU;h=2a22632a82aefe6c28e072dc452bba991bae979c;hb=0391212b73371b839c601079ef1393d6cd71868f;hp=856b582b3cc0a95e35f126315b1e157c12e2a30b;hpb=32a1e647773bffe10c40a1fdff1bfbf73806c4b8;p=git.git diff --git a/PU b/PU index 856b582b..2a22632a 100755 --- a/PU +++ b/PU @@ -3,18 +3,81 @@ # Rebuild "pu" from topic branches. # -git status && exit +git-update-index --refresh || exit +case "$(git-diff-index --name-status HEAD)" in +'') ;; +*) echo 2>&1 "Local modifications exist." + exit 1;; +esac git checkout pu && git reset --hard master && ORIG_HEAD=`git rev-parse ORIG_HEAD` || exit +LF=' +' + +case "$#" in +0) + # interactive ;-) + shift + HH=`cd .git/refs/heads && find -type f | + sed -e 's/^\.\///' \ + -e '/^naster$/d' -e '/^master$/d' -e '/^maint$/d' -e '/^pu$/d'` + while test "$HH" + do + I=0 + echo "0: done" + NHH= + for H in $HH + do + HSHA1=`git-rev-parse --verify $H` || continue + MB=`git-show-branch --merge-base pu $HSHA1` + case "$LF$MB$LF" in + *"$LF$HSHA1$LF"*) continue ;; # already merged. + esac + I=$(($I+1)) + echo -n "$I: " + git-show-branch $H + NHH="${NHH}$H " + done + case "$I" in + 0) + break ;; + esac + HH=$NHH + echo -n "Merge which ones (0 to finish)? " + read ans + case "$ans" in + '' | 0) + break ;; + esac + I=0 + UNUSE= USE= USED= + for H in $HH + do + I=$(($I+1)) + case " $ans " in + *' '$I' '*) + USE="$USE$H " + USED="$USED,$H" + ;; + *) + UNUSE="$UNUSE$H " + ;; + esac + done + USED=`expr "$USED" : ',\(.*\)'` + git pull -n . $USE || exit + # git merge -n "Merge $USED" pu $USE || exit + HH=$UNUSE + done + exit + ;; +esac for H do +# (IFS=",$IFS"; git merge -n "Merge $H" pu $H) || exit (IFS=",$IFS"; git pull -n . $H) || exit done -(IFS=",$IFS"; git show-branch master pu $* $ORIG_HEAD) - - - - +(IFS=",$IFS"; git show-branch master $* pu `git rev-parse --short $ORIG_HEAD`)