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

[PATCH] rebase -i: do leave commit message intact in fixup! chains

From
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
Date
Dec 19, 2020, 00:22 UTC
Message-ID
<pull.818.git.1608337339246.gitgitgadget@gmail.com>
From: Johannes Schindelin <johannes.schindelin@gmx.de>

In 6e98de72c03 (sequencer (rebase -i): add support for the 'fixup' and 'squash' commands, 2017-01-02), this developer introduced a change of behavior by mistake: when encountering a `fixup!` commit (or multiple `fixup!` commits) without any `squash!` commit thrown in, the final `git commit` was invoked with `--cleanup=strip`. Prior to that commit, the commit command had been called without that `--cleanup` option.

Since we explicitly read the original commit message from a file in that case, there is really no sense in forcing that clean-up.

Reported-by: Vojtěch Knyttl <vojtech@knyt.tl>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
    Fix bug in interactive rebases where fixup! cleans up the commit message
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-818%2Fdscho%2Fautosquash-without-scissors-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-818/dscho/autosquash-without-scissors-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/818
 sequencer.c                  | 5 ++---
 t/t3415-rebase-autosquash.sh | 8 ++++++++
 2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/sequencer.c b/sequencer.c
index 8909a467700..749bddd7a1f 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -2001,10 +2001,9 @@ static int do_pick_commit(struct repository *r,
 		flags |= AMEND_MSG;
 		if (!final_fixup)
 			msg_file = rebase_path_squash_msg();
-		else if (file_exists(rebase_path_fixup_msg())) {
-			flags |= CLEANUP_MSG;
+		else if (file_exists(rebase_path_fixup_msg()))
 			msg_file = rebase_path_fixup_msg();
-		} else {
+		else {
 			const char *dest = git_path_squash_msg(r);
 			unlink(dest);
 			if (copy_file(dest, rebase_path_squash_msg(), 0666))
diff --git a/t/t3415-rebase-autosquash.sh b/t/t3415-rebase-autosquash.sh
index 7bab6000dc7..4c83c98b3fc 100755
--- a/t/t3415-rebase-autosquash.sh
+++ b/t/t3415-rebase-autosquash.sh
@@ -440,4 +440,12 @@ test_expect_success 'fixup a fixup' '
 	test XZWY = $(git show | tr -cd W-Z)
 '
 
+test_expect_success 'fixup does not clean up commit message' '
+	oneline="#818" &&
+	git commit --allow-empty -m "$oneline" &&
+	git commit --fixup HEAD --allow-empty &&
+	git rebase -ki --autosquash HEAD~2 &&
+	test "$oneline" = "$(git show -s --format=%s)"
+'
+
 test_done

base-commit: ba2aa15129e59f248d8cdd30404bc78b5178f61d
-- 
gitgitgadget
Next: Martin Ågren
Message 1 of 10 in “rebase -i: do leave commit message intact in fixup! chains”
  1. rebase -i: do leave commit message intact in fixup! chainsJohannes Schindelin via GitGitGadget, Dec 19, 2020
  2. Martin ÅgrenDec 19, 2020
  3. Johannes SchindelinDec 19, 2020
  4. rebase -i: do leave commit message intact in fixup! chainsJohannes Schindelin via GitGitGadget, Jan 8, 2021
  5. Martin ÅgrenJan 12, 2021
  6. Johannes SchindelinJan 28, 2021
  7. Junio C HamanoJan 12, 2021
  8. Johannes SchindelinJan 28, 2021
  9. Junio C HamanoJan 28, 2021
  10. rebase -i: do leave commit message intact in fixup! chainsJohannes Schindelin via GitGitGadget, Jan 28, 2021

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.