# gitk: add cherry-pick with cross-reference action

2 messages from 2026-10-26 to 2026-10-27. Participants: Ralf Habacker, Johannes Sixt.
Thread: https://gitlist.dev/t/66669

## Ralf Habacker, 2026-10-26 18:42

Subject: gitk: add cherry-pick with cross-reference action
Message-ID: <57d4f046-26fc-4dd3-8a90-4132c5941ca4@freenet.de>
URL: https://gitlist.dev/e/57d4f046-26fc-4dd3-8a90-4132c5941ca4%40freenet.de

```
From ae2217025407ff91f3ea3332f94d5b0bdcd01e70 Mon Sep 17 00:00:00 2001
From: Ralf Habacker <ralf.habacker@freenet.de>
Date: Tue, 26 May 2026 22:55:47 +0200
Subject: [PATCH] gitk: add cherry-pick with cross-reference action
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Add a context-menu action to cherry-pick a commit with a reference to
the original commit in the commit message.

This commit closes a gap in gitk’s GUI workflow for projects that
for example require backported commits to remain traceable to their
originals.

Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
---
 gitk-git/gitk | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/gitk-git/gitk b/gitk-git/gitk
index 9506739c50..0c7db0a4d9 100755
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -2859,6 +2859,7 @@ proc makewindow {} {
         {mc "Write commit to file" command writecommit}
         {mc "Create new branch" command mkbranch}
         {mc "Cherry-pick this commit" command cherrypick}
+        {mc "Cherry-pick with cross-reference" command {cherrypick -x}}
         {mc "Reset HEAD branch to here" command resethead}
         {mc "Mark this commit" command markhere}
         {mc "Return to mark" command gotomark}
@@ -9167,13 +9168,13 @@ proc rowmenu {x y id} {
     if {$id ne $nullid && $id ne $nullid2} {
         set menu $rowctxmenu
         if {$mainhead ne {}} {
-            $menu entryconfigure 8 -label [mc "Reset %s branch to here" $mainhead] -state normal
+            $menu entryconfigure 9 -label [mc "Reset %s branch to here" $mainhead] -state normal
         } else {
-            $menu entryconfigure 8 -label [mc "Detached head: can't reset" $mainhead] -state disabled
+            $menu entryconfigure 9 -label [mc "Detached head: can't reset" $mainhead] -state disabled
         }
-        $menu entryconfigure 10 -state $mstate
         $menu entryconfigure 11 -state $mstate
         $menu entryconfigure 12 -state $mstate
+        $menu entryconfigure 13 -state $mstate
     } else {
         set menu $fakerowmenu
     }
@@ -9881,7 +9882,7 @@ proc exec_citool {tool_args {baseid {}}} {
     array set env $save_env
 }

-proc cherrypick {} {
+proc cherrypick {{option "-r"}} {
     global rowmenuid curview
     global mainhead mainheadid
     global gitdir
@@ -9898,7 +9899,7 @@ proc cherrypick {} {
     update
     # Unfortunately git-cherry-pick writes stuff to stderr even when
     # no error occurs, and exec takes that as an indication of error...
-    if {[catch {safe_exec [list sh -c "git cherry-pick -r $rowmenuid 2>&1"]} err]} {
+    if {[catch {safe_exec [list sh -c "git cherry-pick $option $rowmenuid 2>&1"]} err]} {
         notbusy cherrypick
         if {[regexp -line \
                  {Entry '(.*)' (would be overwritten by merge|not uptodate)} \
-- 
2.54.0



```

## Johannes Sixt, 2026-10-27 09:55

Subject: Re: gitk: add cherry-pick with cross-reference action
Message-ID: <004525db-3029-4e99-b93c-ff7ff24e3b4a@kdbg.org>
URL: https://gitlist.dev/e/004525db-3029-4e99-b93c-ff7ff24e3b4a%40kdbg.org
In-Reply-To: <57d4f046-26fc-4dd3-8a90-4132c5941ca4@freenet.de>

```
Am 26.10.26 um 19:42 schrieb Ralf Habacker:
> Add a context-menu action to cherry-pick a commit with a reference to
> the original commit in the commit message.
> 
> This commit closes a gap in gitk’s GUI workflow for projects that
> for example require backported commits to remain traceable to their
> originals.

The patch text is looking good. I picked up the patch and pushed it out
as branch rh/cherry-pick-x to https://github.com/j6t/gitk for others to
consume. But, as I said, I would like to hear more voices that this is a
good thing to include.

-- Hannes



```
