git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v2 2/3] rebase -i: demonstrate a bug with --autosquash

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Jul 7, 2016, 15:52 UTC
Message-ID
<46a5e7960232dc89a1db7728983c8f2e6c939c69.1467906747.git.johannes.schindelin@gmx.de>
In-Reply-To
<cover.1467906747.git.johannes.schindelin@gmx.de>

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>
---
 t/t3415-rebase-autosquash.sh | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)
diff --git a/t/t3415-rebase-autosquash.sh b/t/t3415-rebase-autosquash.sh
index 8f53e54..9b71a49 100755
--- a/t/t3415-rebase-autosquash.sh
+++ b/t/t3415-rebase-autosquash.sh
@@ -271,4 +271,28 @@ test_expect_success 'autosquash with custom inst format' '
 	test 2 = $(git cat-file commit HEAD^ | grep squash | wc -l)
 '
 
+set_backup_editor () {
+	write_script backup-editor.sh <<-\EOF
+	cp "$1" .git/backup-"$(basename "$1")"
+	EOF
+	test_set_editor "$PWD/backup-editor.sh"
+}
+
+test_expect_failure 'autosquash with multiple empty patches' '
+	test_tick &&
+	git commit --allow-empty -m "empty" &&
+	test_tick &&
+	git commit --allow-empty -m "empty2" &&
+	test_tick &&
+	>fixup &&
+	git add fixup &&
+	git commit --fixup HEAD^^ &&
+	(
+		set_backup_editor &&
+		GIT_USE_REBASE_HELPER=false \
+		git rebase -i --force-rebase --autosquash HEAD~4 &&
+		grep empty2 .git/backup-git-rebase-todo
+	)
+'
+
 test_done
-- 
2.9.0.278.g1caae67
Previous: Johannes SchindelinNext: Johannes Schindelin
Message 18 of 20 in “Late edits to the rebase -i tests”
  1. 0/2 Late edits to the rebase -i testsJohannes Schindelin, Jun 29, 2016
  2. 1/2 t3404: fix another typoJohannes Schindelin, Jun 29, 2016
  3. Junio C HamanoJun 29, 2016
  4. Johannes SchindelinJun 29, 2016
  5. Junio C HamanoJun 29, 2016
  6. Johannes SchindelinJun 30, 2016
  7. Pranit BauvaJun 29, 2016
  8. 2/2 t3404: add a test for the --gpg-sign optionJohannes Schindelin, Jun 29, 2016
  9. Junio C HamanoJun 29, 2016
  10. Johannes SchindelinJun 30, 2016
  11. Junio C HamanoJul 1, 2016
  12. Johannes SchindelinJul 2, 2016
  13. Junio C HamanoJul 6, 2016
  14. Johannes SchindelinJul 6, 2016
  15. Junio C HamanoJul 6, 2016
  16. Johannes SchindelinJul 7, 2016
  17. 0/3 Additional rebase -i testsJohannes Schindelin, Jul 7, 2016
  18. 2/3 rebase -i: demonstrate a bug with --autosquashJohannes Schindelin, Jul 7, 2016
  19. 1/3 t3404: add a test for the --gpg-sign optionJohannes Schindelin, Jul 7, 2016
  20. 3/3 rebase -i: we allow extra spaces after fixup!/squash!Johannes Schindelin, Jul 7, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.