1
0
mirror of https://github.com/git/git.git synced 2024-09-28 17:22:20 +02:00

rebase -i --autosquash: demonstrate a problem skipping the last squash

The `git commit --squash` command can be used not only to amend commit
messages and changes, but also to record notes for an upcoming rebase.

For example, when the author information of a given commit is incorrect,
a user might call `git commit --allow-empty -m "Fix author" --squash
<commit>`, to remind them to fix that during the rebase. When the editor
would pop up, the user would simply delete the commit message to abort
the rebase at this stage, fix the author information, and continue with
`git rebase --skip`. (This is a real-world example from the rebase of
Git for Windows onto v2.19.0-rc1.)

However, there is a bug in `git rebase` that will cause the squash
message *not* to be forgotten in this case. It will therefore be reused
in the next fixup/squash chain (if any).

This patch adds a test case to demonstrate this breakage.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
Johannes Schindelin 2018-08-31 16:45:02 -07:00 committed by Junio C Hamano
parent 53f9a3e157
commit 2f3eb68f10

@ -330,4 +330,23 @@ test_expect_success 'wrapped original subject' '
test $base = $parent
'
test_expect_failure 'abort last squash' '
test_when_finished "test_might_fail git rebase --abort" &&
test_when_finished "git checkout master" &&
git checkout -b some-squashes &&
git commit --allow-empty -m first &&
git commit --allow-empty --squash HEAD &&
git commit --allow-empty -m second &&
git commit --allow-empty --squash HEAD &&
test_must_fail git -c core.editor="grep -q ^pick" \
rebase -ki --autosquash HEAD~4 &&
: do not finish the squash, but resolve it manually &&
git commit --allow-empty --amend -m edited-first &&
git rebase --skip &&
git show >actual &&
! grep first actual
'
test_done