git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] t/t3515-cherry-pick-rebase.sh: new testcase demonstrating broken behavior
@ 2024-02-02  9:18 Vegard Nossum
  2024-02-04 11:14 ` Phillip Wood
  0 siblings, 1 reply; 16+ messages in thread
From: Vegard Nossum @ 2024-02-02  9:18 UTC (permalink / raw)
  To: gitster; +Cc: git, Jonathan Nieder, Vegard Nossum, Harshit Mogalapalli

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

Write a known-broken test case for this:

    $ (cd t && ./t3515-cherry-pick-rebase.sh)
    ok 1 - setup
    ok 2 - cherry-pick preserves authorship information
    not ok 3 - cherry-pick inside rebase preserves authorship information # TODO known breakage
    # still have 1 known breakage(s)
    # passed all remaining 2 test(s)
    1..3

Running with --verbose we see the diff between expected and actual:

    --- expected    2024-02-02 08:54:48.954753285 +0000
    +++ actual      2024-02-02 08:54:48.966753294 +0000
    @@ -1 +1 @@
    -Original Author
    +A U Thor

As far as I can tell, this is due to the check in print_advice()
which deletes CHERRY_PICK_HEAD when GIT_CHERRY_PICK_HELP is set,
but I'm not sure what a good fix would be.

Cc: Harshit Mogalapalli <harshit.m.mogalapalli@oracle.com>
Signed-off-by: Vegard Nossum <vegard.nossum@oracle.com>
---
 t/t3515-cherry-pick-rebase.sh | 37 +++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)
 create mode 100755 t/t3515-cherry-pick-rebase.sh

diff --git a/t/t3515-cherry-pick-rebase.sh b/t/t3515-cherry-pick-rebase.sh
new file mode 100755
index 0000000000..ffe6f5fe2a
--- /dev/null
+++ b/t/t3515-cherry-pick-rebase.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+test_description='test cherry-pick during a rebase'
+
+GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME=main
+export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
+
+. ./test-lib.sh
+
+test_expect_success setup '
+	test_commit --author "Original Author <original.author@example.com>" foo file contents1 &&
+	git checkout -b feature &&
+	test_commit --author "Another Author <another.author@example.com>" bar file contents2
+'
+
+test_expect_success 'cherry-pick preserves authorship information' '
+	git checkout -B tmp feature &&
+	test_must_fail git cherry-pick foo &&
+	git add file &&
+	git commit --no-edit &&
+	git log -1 --format='%an' foo >expected &&
+	git log -1 --format='%an' >actual &&
+	test_cmp expected actual
+'
+
+test_expect_failure '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 &&
+	git add file &&
+	git commit --no-edit &&
+	git log -1 --format='%an' foo >expected &&
+	git log -1 --format='%an' >actual &&
+	test_cmp expected actual
+'
+
+test_done
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2024-02-15 17:36 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-02  9:18 [PATCH] t/t3515-cherry-pick-rebase.sh: new testcase demonstrating broken behavior Vegard Nossum
2024-02-04 11:14 ` Phillip Wood
2024-02-05 14:13   ` [PATCH 2/2] sequencer: unset GIT_CHERRY_PICK_HELP for 'exec' commands Vegard Nossum
2024-02-05 14:38     ` Kristoffer Haugsbakk
2024-02-05 23:09       ` Junio C Hamano
2024-02-05 23:14         ` Vegard Nossum
2024-02-06  3:54           ` Junio C Hamano
2024-02-07 14:03             ` Phillip Wood
2024-02-07 16:39               ` Junio C Hamano
2024-02-08  8:48                 ` Vegard Nossum
2024-02-08 14:26                   ` Phillip Wood
2024-02-08 17:20                     ` Junio C Hamano
2024-02-11 11:11                       ` Phillip Wood
2024-02-11 17:05                         ` Junio C Hamano
2024-02-15 14:24                           ` Vegard Nossum
2024-02-15 17:36                             ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).