public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
* cherry-pick: add --show-current-patch
@ 2026-03-11 18:30 Florian Best
  2026-03-11 19:30 ` Phillip Wood
  0 siblings, 1 reply; 4+ messages in thread
From: Florian Best @ 2026-03-11 18:30 UTC (permalink / raw)
  To: git

Hello,

When running `git cherry-pick` over a range of commits, the command may 
stop due to conflicts. At that point Git reports the conflict but does 
not provide an easy way to see which commit is currently being 
cherry-picked or what patch is being applied.

`git rebase` provides a helpful option for this situation:

`git rebase --show-current-patch`

This prints the patch of the commit that is currently being applied. I 
believe a similar feature would be useful for `git cherry-pick`.

Currently, when a conflict occurs during a range cherry-pick (e.g. `git 
cherry-pick A..B`), there is no straightforward command to show the 
patch of the commit being applied. While it is possible to inspect 
`.git/CHERRY_PICK_HEAD`and run something like:

`git show $(cat .git/CHERRY_PICK_HEAD)`

this is not very discoverable and requires manual steps.


Proposed feature

Add a command:

`git cherry-pick --show-current-patch`

which would display the patch of the commit currently being applied 
during an in-progress cherry-pick operation (similar to `git rebase 
--show-current-patch`).

Behavior could be:

  * If a cherry-pick is in progress, show the patch corresponding to 
`CHERRY_PICK_HEAD`.
  * If no cherry-pick is in progress, report an appropriate error.


Motivation

This would help users:

  * understand which commit caused the conflict
  * review the exact changes being applied
  * debug large range cherry-picks more easily

It would also provide feature parity with `git rebase`.

Best regards
Florian

-- 
Florian Best
Open Source Software Engineer

Geschäftsführer: Peter H. Ganten, Stefan Gohmann
HRB 20755 Amtsgericht Bremen
Steuer-Nr.: 71-597-02876

Univention GmbH
Mary-Somerville-Str. 1
28359 Bremen
Germany / Deutschland

📞 Phone : +49 421 22232-0
🖶 Fax   : +49 421 22232-99
✉️best@univention.de
🌐https://www.univention.de / https://www.univention.com

Managing Directors: Peter H. Ganten, Stefan Gohmann
Local court: Amtsgericht Bremen
HRB 20755 / Steuer-Nr.: 71-597-02876

The information contained in this message is confidential or protected 
by law.
If you are not the intended recipient, please contact the sender and 
delete this message.
Any unauthorized copying of this message or unauthorized distribution of 
the information contained herein is prohibited.
Legally required information for business correspondence: Legal Information

Diese E-Mail enthält vertrauliche oder rechtlich geschützte Informationen.
Wenn Sie nicht der beabsichtigte Empfänger sind, informieren Sie bitte 
sofort den Absender und löschen Sie diese E-Mail. Das unbefugte Kopieren 
dieser E-Mail oder die unbefugte Weitergabe der enthaltenen 
Informationen ist nicht gestattet.
Gesetzliche Pflichtangaben für Geschäftskorrespondenz: Datenschutzerklärung

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

* Re: cherry-pick: add --show-current-patch
  2026-03-11 18:30 cherry-pick: add --show-current-patch Florian Best
@ 2026-03-11 19:30 ` Phillip Wood
       [not found]   ` <f2bf231a-2b18-4f1c-9cbc-2b94f669839f@univention.de>
  0 siblings, 1 reply; 4+ messages in thread
From: Phillip Wood @ 2026-03-11 19:30 UTC (permalink / raw)
  To: Florian Best, git

Hi Florian

On 11/03/2026 18:30, Florian Best wrote:
> Hello,
> 
> When running `git cherry-pick` over a range of commits, the command may 
> stop due to conflicts. At that point Git reports the conflict but does 
> not provide an easy way to see which commit is currently being cherry- 
> picked or what patch is being applied.
> 
> `git rebase` provides a helpful option for this situation:
> 
> `git rebase --show-current-patch`
> 
> This prints the patch of the commit that is currently being applied. I 
> believe a similar feature would be useful for `git cherry-pick`.

That option exists for rebase because it originally applied a series of 
patches rather than performing a 3-way merge like cherry-pick and so 
there was no other way of seeing which commit was being processed. With 
cherry-pick you can use

	git show CHERRY_PICK_HEAD

which allows you to add any of the options that you'd use when showing a 
commit. That is more flexible than a "--show-current-patch" option 
because you can restrict the diff to the path that you are interested 
in, or show a word-diff etc. When reverting you can use REVERT_HEAD and 
when rebasing you can use REBASE_HEAD to see the commit being picked. I 
did wonder if the documentation could be improved but for cherry-pick it 
mentions CHERRY_PICK_HEAD in the description section at the top of the page.

Thanks

Phillip

> Currently, when a conflict occurs during a range cherry-pick (e.g. `git 
> cherry-pick A..B`), there is no straightforward command to show the 
> patch of the commit being applied. While it is possible to inspect 
> `.git/CHERRY_PICK_HEAD`and run something like:
> 
> `git show $(cat .git/CHERRY_PICK_HEAD)`
> 
> this is not very discoverable and requires manual steps.
> 
> 
> Proposed feature
> 
> Add a command:
> 
> `git cherry-pick --show-current-patch`
> 
> which would display the patch of the commit currently being applied 
> during an in-progress cherry-pick operation (similar to `git rebase -- 
> show-current-patch`).
> 
> Behavior could be:
> 
>   * If a cherry-pick is in progress, show the patch corresponding to 
> `CHERRY_PICK_HEAD`.
>   * If no cherry-pick is in progress, report an appropriate error.
> 
> 
> Motivation
> 
> This would help users:
> 
>   * understand which commit caused the conflict
>   * review the exact changes being applied
>   * debug large range cherry-picks more easily
> 
> It would also provide feature parity with `git rebase`.
> 
> Best regards
> Florian
> 


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

* Re: cherry-pick: add --show-current-patch
       [not found]   ` <f2bf231a-2b18-4f1c-9cbc-2b94f669839f@univention.de>
@ 2026-03-16 11:03     ` Phillip Wood
  2026-03-17 22:55       ` Florian Best
  0 siblings, 1 reply; 4+ messages in thread
From: Phillip Wood @ 2026-03-16 11:03 UTC (permalink / raw)
  To: Florian Best, phillip.wood; +Cc: Git Mailing List

Hi Florian

On 11/03/2026 19:42, Florian Best wrote:
> Hi Phillip,
> 
> thank you!
> Your reasoning makes sense, and therefore --show-current-patch is 
> probably a bad idea.
> I simply oversaw that complex sentence in the --help/manpage:
> 
>  >          2. The CHERRY_PICK_HEAD ref is set to point at the commit 
> that introduced the change that is difficult to apply.
> 
> Maybe adding "git show CHERRY_PICK_HEAD" to the Examples section of the 
> manpage improves finding it.

That sounds reasonable, are you interested in contributing a patch?

Thanks

Phillip

> Best regards
> Florian
> 
> Am 11.03.26 um 20:30 schrieb Phillip Wood:
>> Hi Florian
>>
>> On 11/03/2026 18:30, Florian Best wrote:
>>> Hello,
>>>
>>> When running `git cherry-pick` over a range of commits, the command 
>>> may stop due to conflicts. At that point Git reports the conflict but 
>>> does not provide an easy way to see which commit is currently being 
>>> cherry- picked or what patch is being applied.
>>>
>>> `git rebase` provides a helpful option for this situation:
>>>
>>> `git rebase --show-current-patch`
>>>
>>> This prints the patch of the commit that is currently being applied. 
>>> I believe a similar feature would be useful for `git cherry-pick`.
>>
>> That option exists for rebase because it originally applied a series 
>> of patches rather than performing a 3-way merge like cherry-pick and 
>> so there was no other way of seeing which commit was being processed. 
>> With cherry-pick you can use
>>
>>     git show CHERRY_PICK_HEAD
>>
>> which allows you to add any of the options that you'd use when showing 
>> a commit. That is more flexible than a "--show-current-patch" option 
>> because you can restrict the diff to the path that you are interested 
>> in, or show a word-diff etc. When reverting you can use REVERT_HEAD 
>> and when rebasing you can use REBASE_HEAD to see the commit being 
>> picked. I did wonder if the documentation could be improved but for 
>> cherry-pick it mentions CHERRY_PICK_HEAD in the description section at 
>> the top of the page.
>>
>> Thanks
>>
>> Phillip
>>
>>> Currently, when a conflict occurs during a range cherry-pick (e.g. 
>>> `git cherry-pick A..B`), there is no straightforward command to show 
>>> the patch of the commit being applied. While it is possible to 
>>> inspect `.git/CHERRY_PICK_HEAD`and run something like:
>>>
>>> `git show $(cat .git/CHERRY_PICK_HEAD)`
>>>
>>> this is not very discoverable and requires manual steps.
>>>
>>>
>>> Proposed feature
>>>
>>> Add a command:
>>>
>>> `git cherry-pick --show-current-patch`
>>>
>>> which would display the patch of the commit currently being applied 
>>> during an in-progress cherry-pick operation (similar to `git rebase 
>>> -- show-current-patch`).
>>>
>>> Behavior could be:
>>>
>>>   * If a cherry-pick is in progress, show the patch corresponding to 
>>> `CHERRY_PICK_HEAD`.
>>>   * If no cherry-pick is in progress, report an appropriate error.
>>>
>>>
>>> Motivation
>>>
>>> This would help users:
>>>
>>>   * understand which commit caused the conflict
>>>   * review the exact changes being applied
>>>   * debug large range cherry-picks more easily
>>>
>>> It would also provide feature parity with `git rebase`.
>>>
>>> Best regards
>>> Florian
>>>
>>
> 


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

* Re: cherry-pick: add --show-current-patch
  2026-03-16 11:03     ` Phillip Wood
@ 2026-03-17 22:55       ` Florian Best
  0 siblings, 0 replies; 4+ messages in thread
From: Florian Best @ 2026-03-17 22:55 UTC (permalink / raw)
  To: phillip.wood; +Cc: Git Mailing List

[-- Attachment #1: Type: text/plain, Size: 4862 bytes --]

Dear Phillip,

attached is a patch suggestion, also available as Github PR: 
https://github.com/git/git/pull/2243

Best regards
Florian

Am 16.03.26 um 12:03 schrieb Phillip Wood:
> Hi Florian
>
> On 11/03/2026 19:42, Florian Best wrote:
>> Hi Phillip,
>>
>> thank you!
>> Your reasoning makes sense, and therefore --show-current-patch is 
>> probably a bad idea.
>> I simply oversaw that complex sentence in the --help/manpage:
>>
>>  >          2. The CHERRY_PICK_HEAD ref is set to point at the commit 
>> that introduced the change that is difficult to apply.
>>
>> Maybe adding "git show CHERRY_PICK_HEAD" to the Examples section of 
>> the manpage improves finding it.
>
> That sounds reasonable, are you interested in contributing a patch?
>
> Thanks
>
> Phillip
>
>> Best regards
>> Florian
>>
>> Am 11.03.26 um 20:30 schrieb Phillip Wood:
>>> Hi Florian
>>>
>>> On 11/03/2026 18:30, Florian Best wrote:
>>>> Hello,
>>>>
>>>> When running `git cherry-pick` over a range of commits, the command 
>>>> may stop due to conflicts. At that point Git reports the conflict 
>>>> but does not provide an easy way to see which commit is currently 
>>>> being cherry- picked or what patch is being applied.
>>>>
>>>> `git rebase` provides a helpful option for this situation:
>>>>
>>>> `git rebase --show-current-patch`
>>>>
>>>> This prints the patch of the commit that is currently being 
>>>> applied. I believe a similar feature would be useful for `git 
>>>> cherry-pick`.
>>>
>>> That option exists for rebase because it originally applied a series 
>>> of patches rather than performing a 3-way merge like cherry-pick and 
>>> so there was no other way of seeing which commit was being 
>>> processed. With cherry-pick you can use
>>>
>>>     git show CHERRY_PICK_HEAD
>>>
>>> which allows you to add any of the options that you'd use when 
>>> showing a commit. That is more flexible than a 
>>> "--show-current-patch" option because you can restrict the diff to 
>>> the path that you are interested in, or show a word-diff etc. When 
>>> reverting you can use REVERT_HEAD and when rebasing you can use 
>>> REBASE_HEAD to see the commit being picked. I did wonder if the 
>>> documentation could be improved but for cherry-pick it mentions 
>>> CHERRY_PICK_HEAD in the description section at the top of the page.
>>>
>>> Thanks
>>>
>>> Phillip
>>>
>>>> Currently, when a conflict occurs during a range cherry-pick (e.g. 
>>>> `git cherry-pick A..B`), there is no straightforward command to 
>>>> show the patch of the commit being applied. While it is possible to 
>>>> inspect `.git/CHERRY_PICK_HEAD`and run something like:
>>>>
>>>> `git show $(cat .git/CHERRY_PICK_HEAD)`
>>>>
>>>> this is not very discoverable and requires manual steps.
>>>>
>>>>
>>>> Proposed feature
>>>>
>>>> Add a command:
>>>>
>>>> `git cherry-pick --show-current-patch`
>>>>
>>>> which would display the patch of the commit currently being applied 
>>>> during an in-progress cherry-pick operation (similar to `git rebase 
>>>> -- show-current-patch`).
>>>>
>>>> Behavior could be:
>>>>
>>>>   * If a cherry-pick is in progress, show the patch corresponding 
>>>> to `CHERRY_PICK_HEAD`.
>>>>   * If no cherry-pick is in progress, report an appropriate error.
>>>>
>>>>
>>>> Motivation
>>>>
>>>> This would help users:
>>>>
>>>>   * understand which commit caused the conflict
>>>>   * review the exact changes being applied
>>>>   * debug large range cherry-picks more easily
>>>>
>>>> It would also provide feature parity with `git rebase`.
>>>>
>>>> Best regards
>>>> Florian
>>>>
>>>
>>
>

-- 
Florian Best
Open Source Software Engineer

Geschäftsführer: Peter H. Ganten, Stefan Gohmann
HRB 20755 Amtsgericht Bremen
Steuer-Nr.: 71-597-02876

Univention GmbH
Mary-Somerville-Str. 1
28359 Bremen
Germany / Deutschland

📞 Phone : +49 421 22232-0
🖶 Fax   : +49 421 22232-99
✉️ best@univention.de
🌐 https://www.univention.de / https://www.univention.com

Managing Directors: Peter H. Ganten, Stefan Gohmann
Local court: Amtsgericht Bremen
HRB 20755 / Steuer-Nr.: 71-597-02876

The information contained in this message is confidential or protected by law.
If you are not the intended recipient, please contact the sender and delete this message.
Any unauthorized copying of this message or unauthorized distribution of the information contained herein is prohibited.
Legally required information for business correspondence: Legal Information

Diese E-Mail enthält vertrauliche oder rechtlich geschützte Informationen.
Wenn Sie nicht der beabsichtigte Empfänger sind, informieren Sie bitte sofort den Absender und löschen Sie diese E-Mail. Das unbefugte Kopieren dieser E-Mail oder die unbefugte Weitergabe der enthaltenen Informationen ist nicht gestattet.
Gesetzliche Pflichtangaben für Geschäftskorrespondenz: Datenschutzerklärung


[-- Attachment #2: 0001-docs-cherry-pick-document-CHERRY_PICK_HEAD-ref.patch --]
[-- Type: text/x-patch, Size: 1064 bytes --]

From 8c9c2bd986c4e24c0f8715c5c0b2a97a4d6ad982 Mon Sep 17 00:00:00 2001
From: Florian Best <best@univention.de>
Date: Tue, 17 Mar 2026 23:49:44 +0100
Subject: [PATCH] docs(cherry-pick): document CHERRY_PICK_HEAD ref

Signed-off-by: Florian Best <best@univention.de>
---
 Documentation/git-cherry-pick.adoc | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git Documentation/git-cherry-pick.adoc Documentation/git-cherry-pick.adoc
index 42b41923d5..21de8bbb0e 100644
--- Documentation/git-cherry-pick.adoc
+++ Documentation/git-cherry-pick.adoc
@@ -228,6 +228,12 @@ EXAMPLES
 	so the result can be inspected and made into a single new
 	commit if suitable.
 
+`git show CHERRY_PICK_HEAD`::
+
+	Show the commit currently being applied when a cherry-pick
+	stops due to conflicts. The `CHERRY_PICK_HEAD` reference
+	identifies this commit.
+
 The following sequence attempts to backport a patch, bails out because
 the code the patch applies to has changed too much, and then tries
 again, this time exercising more care about matching up context lines.
-- 
2.39.5


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

end of thread, other threads:[~2026-03-17 22:55 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-11 18:30 cherry-pick: add --show-current-patch Florian Best
2026-03-11 19:30 ` Phillip Wood
     [not found]   ` <f2bf231a-2b18-4f1c-9cbc-2b94f669839f@univention.de>
2026-03-16 11:03     ` Phillip Wood
2026-03-17 22:55       ` Florian Best

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox