Code

Merge branch 'jc/cherry-pick' (early part)
[git.git] / git-rebase.sh
index c059749bbd5bc1e5bf4103c09b4935c46c965431..ff66af3ba8348ff86b25c91a1875b93f885a048c 100755 (executable)
@@ -18,8 +18,7 @@ original <branch> and remove the .dotest working files, use the command
 git rebase --abort instead.
 
 Note that if <branch> is not specified on the command line, the
-currently checked out branch is used.  You must be in the top
-directory of your project to start (or continue) a rebase.
+currently checked out branch is used.
 
 Example:       git-rebase master~1 topic
 
@@ -29,6 +28,7 @@ Example:       git-rebase master~1 topic
 '
 
 SUBDIRECTORY_OK=Yes
+OPTIONS_SPEC=
 . git-sh-setup
 set_reflog_action rebase
 require_work_tree
@@ -60,7 +60,7 @@ continue_merge () {
        fi
 
        cmt=`cat "$dotest/current"`
-       if ! git diff-index --quiet HEAD
+       if ! git diff-index --quiet HEAD --
        then
                if ! git-commit -C "$cmt"
                then
@@ -178,6 +178,7 @@ do
                exit
                ;;
        --skip)
+               git reset --hard HEAD || exit $?
                if test -d "$dotest"
                then
                        git rerere clear
@@ -206,16 +207,15 @@ do
                if test -d "$dotest"
                then
                        move_to_original_branch
-                       rm -r "$dotest"
                elif test -d .dotest
                then
                        dotest=.dotest
                        move_to_original_branch
-                       rm -r .dotest
                else
                        die "No rebase in progress?"
                fi
-               git reset --hard ORIG_HEAD
+               git reset --hard $(cat $dotest/orig-head)
+               rm -r "$dotest"
                exit
                ;;
        --onto)
@@ -283,7 +283,7 @@ fi
 
 # The tree must be really really clean.
 git update-index --refresh || exit
-diff=$(git diff-index --cached --name-status -r HEAD)
+diff=$(git diff-index --cached --name-status -r HEAD --)
 case "$diff" in
 ?*)    echo "cannot rebase: your index is not up-to-date"
        echo "$diff"
@@ -375,7 +375,7 @@ fi
 if test -z "$do_merge"
 then
        git format-patch -k --stdout --full-index --ignore-if-in-upstream "$upstream"..ORIG_HEAD |
-       git am $git_am_opt --binary -3 -k --resolvemsg="$RESOLVEMSG" &&
+       git am $git_am_opt --rebasing --resolvemsg="$RESOLVEMSG" &&
        move_to_original_branch
        ret=$?
        test 0 != $ret -a -d .dotest &&