Code

t/README: start testing porcelainish
[git.git] / git-rebase.sh
index 91594775e6aad4ebe924506e779c51ea5333ad37..3945e067141ec1bc87456179a59de8f692bdf9fa 100755 (executable)
@@ -34,11 +34,6 @@ When you have resolved this problem run \"git rebase --continue\".
 If you would prefer to skip this patch, instead run \"git rebase --skip\".
 To restore the original branch and stop rebasing run \"git rebase --abort\".
 "
-
-MRESOLVEMSG="
-When you have resolved this problem run \"git rebase --continue\".
-To restore the original branch and stop rebasing run \"git rebase --abort\".
-"
 unset newbase
 strategy=recursive
 do_merge=
@@ -54,20 +49,26 @@ continue_merge () {
        then
                echo "You still have unmerged paths in your index"
                echo "did you forget update-index?"
-               die "$MRESOLVEMSG"
+               die "$RESOLVEMSG"
        fi
 
        if test -n "`git-diff-index HEAD`"
        then
-               git-commit -C "`cat $dotest/current`"
+               if ! git-commit -C "`cat $dotest/current`"
+               then
+                       echo "Commit failed, please do not call \"git commit\""
+                       echo "directly, but instead do one of the following: "
+                       die "$RESOLVEMSG"
+               fi
+               printf "Committed: %0${prec}d" $msgnum
        else
-               echo "Previous merge succeeded automatically"
+               printf "Already applied: %0${prec}d" $msgnum
        fi
+       echo ' '`git-rev-list --pretty=oneline -1 HEAD | \
+                               sed 's/^[a-f0-9]\+ //'`
 
        prev_head=`git-rev-parse HEAD^0`
-
        # save the resulting commit so we can read-tree on it later
-       echo "$prev_head" > "$dotest/cmt.$msgnum.result"
        echo "$prev_head" > "$dotest/prev_head"
 
        # onto the next patch:
@@ -82,15 +83,15 @@ call_merge () {
        rv=$?
        case "$rv" in
        0)
-               git-commit -C "$cmt" || die "commit failed: $MRESOLVEMSG"
+               return
                ;;
        1)
                test -d "$GIT_DIR/rr-cache" && git-rerere
-               die "$MRESOLVEMSG"
+               die "$RESOLVEMSG"
                ;;
        2)
                echo "Strategy: $rv $strategy failed, try another" 1>&2
-               die "$MRESOLVEMSG"
+               die "$RESOLVEMSG"
                ;;
        *)
                die "Unknown exit code ($rv) from command:" \
@@ -100,23 +101,6 @@ call_merge () {
 }
 
 finish_rb_merge () {
-       set -e
-
-       msgnum=1
-       echo "Finalizing rebased commits..."
-       git-reset --hard "`cat $dotest/onto`"
-       end="`cat $dotest/end`"
-       while test "$msgnum" -le "$end"
-       do
-               git-read-tree `cat "$dotest/cmt.$msgnum.result"`
-               git-checkout-index -q -f -u -a
-               git-commit -C "`cat $dotest/cmt.$msgnum`"
-
-               printf "Committed %0${prec}d" $msgnum
-               echo ' '`git-rev-list --pretty=oneline -1 HEAD | \
-                                       sed 's/^[a-f0-9]\+ //'`
-               msgnum=$(($msgnum + 1))
-       done
        rm -r "$dotest"
        echo "All done."
 }
@@ -153,7 +137,18 @@ do
        --skip)
                if test -d "$dotest"
                then
-                       die "--skip is not supported when using --merge"
+                       prev_head="`cat $dotest/prev_head`"
+                       end="`cat $dotest/end`"
+                       msgnum="`cat $dotest/msgnum`"
+                       msgnum=$(($msgnum + 1))
+                       onto="`cat $dotest/onto`"
+                       while test "$msgnum" -le "$end"
+                       do
+                               call_merge "$msgnum"
+                               continue_merge
+                       done
+                       finish_rb_merge
+                       exit
                fi
                git am -3 --skip --resolvemsg="$RESOLVEMSG"
                exit
@@ -184,7 +179,7 @@ do
        -s|--s|--st|--str|--stra|--strat|--strate|--strateg|--strategy)
                case "$#,$1" in
                *,*=*)
-                       strategy=`expr "$1" : '-[^=]*=\(.*\)'` ;;
+                       strategy=`expr "z$1" : 'z-[^=]*=\(.*\)'` ;;
                1,*)
                        usage ;;
                *)