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

[PATCH 4/4] rebase -r: fix merge -c with a merge strategy

From
PGPhillip Wood via GitGitGadget <gitgitgadget@gmail.com>
Date
Aug 13, 2021, 13:07 UTC
Message-ID
<f2a2e3531a181f68cee43f832045633aee519fb8.1628860053.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.1015.git.1628860053.gitgitgadget@gmail.com>
From: Phillip Wood <phillip.wood@dunelm.org.uk>

If a rebase is started with a --strategy option other than "ort" or "recursive" then "merge -c" does not allow the user to reword the commit message.

Signed-off-by: Phillip Wood <phillip.wood@dunelm.org.uk>
---
 sequencer.c              |  5 ++++-
 t/t3430-rebase-merges.sh | 18 ++++++++++++++++++
 2 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/sequencer.c b/sequencer.c
index c2cba5ed4b1..a19980f62d9 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -3934,7 +3934,10 @@ static int do_merge(struct repository *r,
 				strvec_pushf(&cmd.args,
 					     "-X%s", opts->xopts[k]);
 		}
-		strvec_push(&cmd.args, "--no-edit");
+		if (!(flags & TODO_EDIT_MERGE_MSG))
+			strvec_push(&cmd.args, "--no-edit");
+		else
+			strvec_push(&cmd.args, "--edit");
 		strvec_push(&cmd.args, "--no-ff");
 		strvec_push(&cmd.args, "--no-log");
 		strvec_push(&cmd.args, "--no-stat");
diff --git a/t/t3430-rebase-merges.sh b/t/t3430-rebase-merges.sh
index 183c3a23838..43c82d9a33b 100755
--- a/t/t3430-rebase-merges.sh
+++ b/t/t3430-rebase-merges.sh
@@ -187,6 +187,24 @@ test_expect_success 'merge -c commits before rewording and reloads todo-list' '
 	check_reworded_commits E H
 '
 
+test_expect_success 'merge -c rewords when a strategy is given' '
+	git checkout -b merge-c-with-strategy H &&
+	write_script git-merge-override <<-\EOF &&
+	echo overridden$1 >G.t
+	git add G.t
+	EOF
+
+	PATH="$PWD:$PATH" \
+	GIT_SEQUENCE_EDITOR="echo merge -c H G >" \
+	GIT_EDITOR="echo edited >>" \
+		git rebase --no-ff -ir -s override -Xxopt E &&
+	test_write_lines overridden--xopt >expect &&
+	test_cmp expect G.t &&
+	test_write_lines H "" edited "" >expect &&
+	git log --format=%B -1 >actual &&
+	test_cmp expect actual
+
+'
 test_expect_success 'with a branch tip that was cherry-picked already' '
 	git checkout -b already-upstream main &&
 	base="$(git rev-parse --verify HEAD)" &&
-- 
gitgitgadget
Previous: Phillip WoodNext: Johannes Schindelin
Message 7 of 15 in “rebase -r: some merge related fixes”
  1. 0/4 rebase -r: some merge related fixesPhillip Wood via GitGitGadget, Aug 13, 2021
  2. 1/4 rebase -r: make 'merge -c' behave like rewordPhillip Wood via GitGitGadget, Aug 13, 2021
  3. 2/4 rebase -i: Add another reword testPhillip Wood via GitGitGadget, Aug 13, 2021
  4. 3/4 rebase -r: don't write .git/MERGE_MSG when fast-forwardingPhillip Wood via GitGitGadget, Aug 13, 2021
  5. SZEDER GáborAug 17, 2021
  6. Phillip WoodAug 19, 2021
  7. 4/4 rebase -r: fix merge -c with a merge strategyPhillip Wood via GitGitGadget, Aug 13, 2021
  8. Johannes SchindelinAug 14, 2021
  9. Phillip WoodAug 19, 2021
  10. 0/4 rebase -r: some merge related fixesPhillip Wood via GitGitGadget, Aug 20, 2021
  11. 1/4 rebase -r: make 'merge -c' behave like rewordPhillip Wood via GitGitGadget, Aug 20, 2021
  12. 2/4 rebase -i: Add another reword testPhillip Wood via GitGitGadget, Aug 20, 2021
  13. 3/4 rebase -r: don't write .git/MERGE_MSG when fast-forwardingPhillip Wood via GitGitGadget, Aug 20, 2021
  14. 4/4 rebase -r: fix merge -c with a merge strategyPhillip Wood via GitGitGadget, Aug 20, 2021
  15. Johannes SchindelinAug 24, 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.