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

[PATCH 2/2] sequencer: unset GIT_CHERRY_PICK_HELP for 'exec' commands

From
Vegard Nossum <vegard.nossum@oracle.com>
Date
Feb 5, 2024, 14:13 UTC
Message-ID
<20240205141335.762947-1-vegard.nossum@oracle.com>
In-Reply-To
<0adb1068-ef10-44ed-ad1d-e0927a09245d@gmail.com>

Running "git cherry-pick" as an x-command in the rebase plan loses the original authorship information.

To fix this, unset GIT_CHERRY_PICK_HELP for 'exec' commands.
Link: https://lore.kernel.org/git/0adb1068-ef10-44ed-ad1d-e0927a09245d@gmail.com/
Suggested-by: Phillip Wood <phillip.wood123@gmail.com>
Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
---
 sequencer.c                   | 1 +
 t/t3515-cherry-pick-rebase.sh | 2 +-
 2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/sequencer.c b/sequencer.c
index 91de546b32..f49a871ac0 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -3641,6 +3641,7 @@ static int do_exec(struct repository *r, const char *command_line)
 	fprintf(stderr, _("Executing: %s\n"), command_line);
 	cmd.use_shell = 1;
 	strvec_push(&cmd.args, command_line);
+	strvec_push(&cmd.env, "GIT_CHERRY_PICK_HELP");
 	status = run_command(&cmd);
 
 	/* force re-reading of the cache */
diff --git a/t/t3515-cherry-pick-rebase.sh b/t/t3515-cherry-pick-rebase.sh
index ffe6f5fe2a..5cb2b96f66 100755
--- a/t/t3515-cherry-pick-rebase.sh
+++ b/t/t3515-cherry-pick-rebase.sh
@@ -23,7 +23,7 @@ test_expect_success 'cherry-pick preserves authorship information' '
 	test_cmp expected actual
 '
 
-test_expect_failure 'cherry-pick inside rebase preserves authorship information' '
+test_expect_success 'cherry-pick inside rebase preserves authorship information' '
 	git checkout -B tmp feature &&
 	echo "x git cherry-pick -x foo" >rebase-plan &&
 	test_must_fail env GIT_SEQUENCE_EDITOR="cp rebase-plan" git rebase -i feature &&
-- 
2.34.1
Previous: Phillip WoodNext: Kristoffer Haugsbakk
Message 3 of 16 in “t/t3515-cherry-pick-rebase.sh: new testcase demonstrating broken behavior”
  1. t/t3515-cherry-pick-rebase.sh: new testcase demonstrating broken behaviorVegard Nossum, Feb 2, 2024
  2. Phillip WoodFeb 4, 2024
  3. 2/2 sequencer: unset GIT_CHERRY_PICK_HELP for 'exec' commandsVegard Nossum, Feb 5, 2024
  4. Kristoffer HaugsbakkFeb 5, 2024
  5. Junio C HamanoFeb 5, 2024
  6. Vegard NossumFeb 5, 2024
  7. Junio C HamanoFeb 6, 2024
  8. Phillip WoodFeb 7, 2024
  9. Junio C HamanoFeb 7, 2024
  10. Vegard NossumFeb 8, 2024
  11. Phillip WoodFeb 8, 2024
  12. Junio C HamanoFeb 8, 2024
  13. Phillip WoodFeb 11, 2024
  14. Junio C HamanoFeb 11, 2024
  15. Vegard NossumFeb 15, 2024
  16. Junio C HamanoFeb 15, 2024

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.