Skip to content

Commit 29dce32

Browse files
committed
Merge branch 'js/rebase-i-clean-up-upon-continue-to-skip' into maint
Abandoning an already applied change in "git rebase -i" with "--continue" left CHERRY_PICK_HEAD and confused later steps. * js/rebase-i-clean-up-upon-continue-to-skip: rebase -i: do not leave a CHERRY_PICK_HEAD file behind t3404: demonstrate CHERRY_PICK_HEAD bug
2 parents de67af4 + 0e0aff4 commit 29dce32

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

git-rebase--interactive.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,11 @@ continue)
849849
# do we have anything to commit?
850850
if git diff-index --cached --quiet HEAD --
851851
then
852-
: Nothing to commit -- skip this
852+
# Nothing to commit -- skip this commit
853+
854+
test ! -f "$GIT_DIR"/CHERRY_PICK_HEAD ||
855+
rm "$GIT_DIR"/CHERRY_PICK_HEAD ||
856+
die "Could not remove CHERRY_PICK_HEAD"
853857
else
854858
if ! test -f "$author_script"
855859
then

t/t3404-rebase-interactive.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1102,4 +1102,25 @@ test_expect_success 'rebase -i commits that overwrite untracked files (no ff)' '
11021102
test $(git cat-file commit HEAD | sed -ne \$p) = I
11031103
'
11041104

1105+
test_expect_success 'rebase --continue removes CHERRY_PICK_HEAD' '
1106+
git checkout -b commit-to-skip &&
1107+
for double in X 3 1
1108+
do
1109+
test_seq 5 | sed "s/$double/&&/" >seq &&
1110+
git add seq &&
1111+
test_tick &&
1112+
git commit -m seq-$double
1113+
done &&
1114+
git tag seq-onto &&
1115+
git reset --hard HEAD~2 &&
1116+
git cherry-pick seq-onto &&
1117+
set_fake_editor &&
1118+
test_must_fail env FAKE_LINES= git rebase -i seq-onto &&
1119+
test -d .git/rebase-merge &&
1120+
git rebase --continue &&
1121+
git diff --exit-code seq-onto &&
1122+
test ! -d .git/rebase-merge &&
1123+
test ! -f .git/CHERRY_PICK_HEAD
1124+
'
1125+
11051126
test_done

0 commit comments

Comments
 (0)