Code

Merge branch 'ic/maint-rebase-i-abort'
authorJunio C Hamano <gitster@pobox.com>
Mon, 21 Jun 2010 13:02:50 +0000 (06:02 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 21 Jun 2010 13:02:50 +0000 (06:02 -0700)
* ic/maint-rebase-i-abort:
  rebase -i: Abort cleanly if new base cannot be checked out

git-rebase--interactive.sh
t/t3404-rebase-interactive.sh

index 436b7f5977c05c347debc12130f822af482c03e3..6b86abc64bfe0034caf23cf9530955128766de32 100755 (executable)
@@ -974,8 +974,9 @@ EOF
 
                test -d "$REWRITTEN" || test -n "$NEVER_FF" || skip_unnecessary_picks
 
+               output git checkout $ONTO || die_abort "could not detach HEAD"
                git update-ref ORIG_HEAD $HEAD
-               output git checkout $ONTO && do_rest
+               do_rest
                ;;
        esac
        shift
index 6668907ec5c5ba196c39fd9a2097050d92ccbe57..ee9a1b25e6a35adcb2350068d3b63b50bc9c24b3 100755 (executable)
@@ -146,6 +146,16 @@ test_expect_success 'abort' '
        ! test -d .git/rebase-merge
 '
 
+test_expect_success 'abort with error when new base cannot be checked out' '
+       git rm --cached file1 &&
+       git commit -m "remove file in base" &&
+       test_must_fail git rebase -i master > output 2>&1 &&
+       grep "Untracked working tree file .file1. would be overwritten" \
+               output &&
+       ! test -d .git/rebase-merge &&
+       git reset --hard HEAD^
+'
+
 test_expect_success 'retain authorship' '
        echo A > file7 &&
        git add file7 &&