Skip to content

Commit b2ebbd8

Browse files
committed
Merge branch 'ic/maint-rebase-i-abort' into maint
* ic/maint-rebase-i-abort: rebase -i: Abort cleanly if new base cannot be checked out
2 parents 81b43b5 + b096374 commit b2ebbd8

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

git-rebase--interactive.sh

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -974,8 +974,9 @@ EOF
974974

975975
test -d "$REWRITTEN" || test -n "$NEVER_FF" || skip_unnecessary_picks
976976

977+
output git checkout $ONTO || die_abort "could not detach HEAD"
977978
git update-ref ORIG_HEAD $HEAD
978-
output git checkout $ONTO && do_rest
979+
do_rest
979980
;;
980981
esac
981982
shift

t/t3404-rebase-interactive.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,16 @@ test_expect_success 'abort' '
146146
! test -d .git/rebase-merge
147147
'
148148

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+
149159
test_expect_success 'retain authorship' '
150160
echo A > file7 &&
151161
git add file7 &&

0 commit comments

Comments
 (0)