]> git.ipfire.org Git - thirdparty/git.git/commitdiff
sequencer: unset GIT_CHERRY_PICK_HELP for 'exec' commands
authorVegard Nossum <vegard.nossum@oracle.com>
Fri, 2 Feb 2024 09:18:50 +0000 (10:18 +0100)
committerJunio C Hamano <gitster@pobox.com>
Thu, 8 Feb 2024 17:17:55 +0000 (09:17 -0800)
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.

Helped-by: Phillip Wood <phillip.wood123@gmail.com>
Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
sequencer.c
t/t3404-rebase-interactive.sh

index d584cac8ed9307caad0f8a9ede98d1f57ceab874..ed30ceaf8b9eaf3a021254022e8df78946cbca2b 100644 (file)
@@ -3647,6 +3647,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 */
index c5f30554c6f356742732f8979a55c872441fb159..84a92d6da08bf717d15c35dd3f0871989008ffdb 100755 (executable)
@@ -153,6 +153,18 @@ test_expect_success 'rebase -i with the exec command checks tree cleanness' '
        git rebase --continue
 '
 
+test_expect_success 'cherry-pick works with rebase --exec' '
+       test_when_finished "git cherry-pick --abort; \
+                           git rebase --abort; \
+                           git checkout primary" &&
+       echo "exec git cherry-pick G" >todo &&
+       (
+               set_replace_editor todo &&
+               test_must_fail git rebase -i D D
+       ) &&
+       test_cmp_rev G CHERRY_PICK_HEAD
+'
+
 test_expect_success 'rebase -x with empty command fails' '
        test_when_finished "git rebase --abort ||:" &&
        test_must_fail env git rebase -x "" @ 2>actual &&