From 3e4574885f7c0c9e4a3a47dcd3373fa91ab17547 Mon Sep 17 00:00:00 2001 From: Aleksei Sviridkin Date: Sat, 5 Sep 2026 20:13:31 +0300 Subject: [PATCH 1/2] t3507: check no CHERRY_PICK_HEAD after conflicting --no-commit Whether CHERRY_PICK_HEAD is written depends on the command, on whether the merge started, and on --no-commit, all in one condition in do_pick_commit(). The suite checks the clean --no-commit pick; nothing checks the conflicting one. The test that already runs a conflicting --no-commit pick compares the advice the command prints, which is what tells us it stopped on a conflict. Assert the ref is missing there too. Signed-off-by: Aleksei Sviridkin Signed-off-by: Junio C Hamano --- t/t3507-cherry-pick-conflict.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/t/t3507-cherry-pick-conflict.sh b/t/t3507-cherry-pick-conflict.sh index 44596cb1e8..aa004d929b 100755 --- a/t/t3507-cherry-pick-conflict.sh +++ b/t/t3507-cherry-pick-conflict.sh @@ -79,7 +79,8 @@ test_expect_success 'advice from failed cherry-pick --no-commit' " EOF test_must_fail git cherry-pick --no-commit picked 2>actual && - test_cmp expected actual + test_cmp expected actual && + test_ref_missing CHERRY_PICK_HEAD " test_expect_success 'failed cherry-pick sets CHERRY_PICK_HEAD' ' From 81c1e0b397da27b8763bae83939c1e8c56258b49 Mon Sep 17 00:00:00 2001 From: Aleksei Sviridkin Date: Sat, 5 Sep 2026 20:13:32 +0300 Subject: [PATCH 2/2] doc: cherry-pick: note --no-commit skips CHERRY_PICK_HEAD The list of what happens when a change is hard to apply states without qualification that CHERRY_PICK_HEAD is set. Under --no-commit it is not: d7e5c0cbfb (Introduce CHERRY_PICK_HEAD, 2011-02-19) skips the ref on purpose there, presuming the user intends to further edit the result and possibly pick more commits on top. The option's own description says nothing about the ref or about authorship. "git commit" reads the author of a cherry-pick from CHERRY_PICK_HEAD, so without it a plain commit records you as the author. Say so where the option is described, and say that this is the point of the option rather than a wrinkle: what is being built is the user's own work, not a reproduction of the original commit. Signed-off-by: Aleksei Sviridkin Signed-off-by: Junio C Hamano --- Documentation/git-cherry-pick.adoc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Documentation/git-cherry-pick.adoc b/Documentation/git-cherry-pick.adoc index 42b41923d5..f4cd8b9db7 100644 --- a/Documentation/git-cherry-pick.adoc +++ b/Documentation/git-cherry-pick.adoc @@ -25,7 +25,8 @@ happens: 1. The current branch and `HEAD` pointer stay at the last commit successfully made. 2. The `CHERRY_PICK_HEAD` ref is set to point at the commit that - introduced the change that is difficult to apply. + introduced the change that is difficult to apply, unless the + `--no-commit` option was given. 3. Paths in which the change applied cleanly are updated both in the index file and in your working tree. 4. For conflicting paths, the index file records up to three @@ -101,6 +102,11 @@ OPTIONS + This is useful when cherry-picking more than one commits' effect to your index in a row. ++ +This option does not record `CHERRY_PICK_HEAD`, so a plain `git commit` +afterwards records you as the author. That is by design: what you are +building is your own work, which you keep changing before committing, +rather than a reproduction of the original commit. -s:: --signoff::