]> asedeno.scripts.mit.edu Git - git.git/blobdiff - git-rebase.sh
git-rebase: report checkout failure
[git.git] / git-rebase.sh
index 9b13b833cb5762542848ee3e85e23d3ca0f76fa6..7825f88952490705fa5272724c92cccff057cc12 100755 (executable)
@@ -60,7 +60,7 @@ continue_merge () {
        fi
 
        cmt=`cat "$dotest/current"`
-       if ! git diff-index --quiet HEAD --
+       if ! git diff-index --quiet --ignore-submodules HEAD --
        then
                if ! git commit --no-verify -C "$cmt"
                then
@@ -150,7 +150,10 @@ while test $# != 0
 do
        case "$1" in
        --continue)
-               git diff-files --quiet || {
+               test -d "$dotest" -o -d .dotest ||
+                       die "No rebase in progress?"
+
+               git diff-files --quiet --ignore-submodules || {
                        echo "You must edit all merge conflicts and then"
                        echo "mark them as resolved using git add"
                        exit 1
@@ -178,6 +181,9 @@ do
                exit
                ;;
        --skip)
+               test -d "$dotest" -o -d .dotest ||
+                       die "No rebase in progress?"
+
                git reset --hard HEAD || exit $?
                if test -d "$dotest"
                then
@@ -203,18 +209,18 @@ do
                exit
                ;;
        --abort)
+               test -d "$dotest" -o -d .dotest ||
+                       die "No rebase in progress?"
+
                git rerere clear
                if test -d "$dotest"
                then
                        move_to_original_branch
-               elif test -d .dotest
-               then
+               else
                        dotest=.dotest
                        move_to_original_branch
-               else
-                       die "No rebase in progress?"
                fi
-               git reset --hard $(cat $dotest/orig-head)
+               git reset --hard $(cat "$dotest/orig-head")
                rm -r "$dotest"
                exit
                ;;
@@ -282,8 +288,8 @@ else
 fi
 
 # The tree must be really really clean.
-git update-index --refresh || exit
-diff=$(git diff-index --cached --name-status -r HEAD --)
+git update-index --ignore-submodules --refresh || exit
+diff=$(git diff-index --cached --name-status -r --ignore-submodules HEAD --)
 case "$diff" in
 ?*)    echo "cannot rebase: your index is not up-to-date"
        echo "$diff"
@@ -353,7 +359,7 @@ orig_head=$branch
 mb=$(git merge-base "$onto" "$branch")
 if test "$upstream" = "$onto" && test "$mb" = "$onto" &&
        # linear history?
-       ! git rev-list --parents "$onto".."$branch" | grep " .* " > /dev/null
+       ! (git rev-list --parents "$onto".."$branch" | grep " .* ") > /dev/null
 then
        # Lazily switch to the target branch if needed...
        test -z "$switch_to" || git checkout "$switch_to"
@@ -370,9 +376,7 @@ fi
 
 # Detach HEAD and reset the tree
 echo "First, rewinding head to replay your work on top of it..."
-git checkout "$onto^0" >/dev/null 2>&1 ||
-       die "could not detach HEAD"
-# git reset --hard "$onto^0"
+git checkout -q "$onto^0" || die "could not detach HEAD"
 
 # If the $onto is a proper descendant of the tip of the branch, then
 # we just fast forwarded.