@matheusbsbs / matheus-bagliano / commits / b096374f4a
Fork 0

rebase -i: Abort cleanly if new base cannot be checked out

Untracked content in the working tree may prevent rebase -i from checking out the new base onto which it wants to replay commits, if the new base commit includes files at those (now untracked) paths. Currently, rebase -i dies uncleanly in this situation, updating ORIG_HEAD and leaving a useless .git/rebase-merge directory, with which the user can do nothing useful except rebase --abort. Make rebase -i abort the procedure itself instead, as non-interactive rebase already does, and add a test for this behavior. Signed-off-by: Ian Ward Comfort <icomfort@stanford.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Ian Ward Comfort committed Jun 8, 2010 at 01:16 UTC b096374f4a2cec0403378c1e9b4fb5fe37b517f4
2 files changed +12 -1
git-rebase--interactive.sh
+2 -1
@@ -974,8 +974,9 @@ EOF
974
975 test -d "$REWRITTEN" || test -n "$NEVER_FF" || skip_unnecessary_picks
976
977 + output git checkout $ONTO || die_abort "could not detach HEAD"
978 git update-ref ORIG_HEAD $HEAD
978 - output git checkout $ONTO && do_rest
979 + do_rest
980 ;;
981 esac
982 shift
t/t3404-rebase-interactive.sh
+10
@@ -146,6 +146,16 @@ test_expect_success 'abort' '
146 ! test -d .git/rebase-merge
147 '
148
149 +test_expect_success 'abort with error when new base cannot be checked out' '
150 + git rm --cached file1 &&
151 + git commit -m "remove file in base" &&
152 + test_must_fail git rebase -i master > output 2>&1 &&
153 + grep "Untracked working tree file .file1. would be overwritten" \
154 + output &&
155 + ! test -d .git/rebase-merge &&
156 + git reset --hard HEAD^
157 +'
158 +
159 test_expect_success 'retain authorship' '
160 echo A > file7 &&
161 git add file7 &&