rebase -i: demonstrate a bug with --autosquash

When rearranging the edit script, we happily mistake the comment character for a command, and the command for a SHA-1. As a consequence, when we move fixup! and squash! commits, our logic to skip lines with already handled SHA-1s mistakenly skips anything but the first commented-out pick line, too. The upcoming rebase--helper patches will address this bug, therefore we do not need to make the current autosquash code even more complex than it already is, just to fix this bug. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Schindelin committed Jul 7, 2016 at 17:52 UTC c94e963b537be0371d4616ec4806b01b477feae0
1 file changed +24
t/t3415-rebase-autosquash.sh
+24
@@ -271,4 +271,28 @@ test_expect_success 'autosquash with custom inst format' '
271 test 2 = $(git cat-file commit HEAD^ | grep squash | wc -l)
272 '
273
274 +set_backup_editor () {
275 + write_script backup-editor.sh <<-\EOF
276 + cp "$1" .git/backup-"$(basename "$1")"
277 + EOF
278 + test_set_editor "$PWD/backup-editor.sh"
279 +}
280 +
281 +test_expect_failure 'autosquash with multiple empty patches' '
282 + test_tick &&
283 + git commit --allow-empty -m "empty" &&
284 + test_tick &&
285 + git commit --allow-empty -m "empty2" &&
286 + test_tick &&
287 + >fixup &&
288 + git add fixup &&
289 + git commit --fixup HEAD^^ &&
290 + (
291 + set_backup_editor &&
292 + GIT_USE_REBASE_HELPER=false \
293 + git rebase -i --force-rebase --autosquash HEAD~4 &&
294 + grep empty2 .git/backup-git-rebase-todo
295 + )
296 +'
297 +
298 test_done