Git development
 help / color / mirror / Atom feed
* [PATCH] gitk: add cherry-pick -x context menu action
@ 2026-10-24  9:40 Ralf Habacker
  2026-10-24 15:52 ` Johannes Sixt
  0 siblings, 1 reply; 3+ messages in thread
From: Ralf Habacker @ 2026-10-24  9:40 UTC (permalink / raw)
  To: git; +Cc: Ralf Habacker




[-- Attachment #2: 0001-gitk-add-cherry-pick-x-context-menu-action.patch --]
[-- Type: text/x-patch, Size: 9638 bytes --]

From b42c14732770444652179e96a61022fe450e6615 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 -x context menu action
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

For example, this command is very useful for cherry-picking
commits into a stable branch using a reference—something that
otherwise can only be done from the command line.

Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
---
 gitk-git/gitk        | 15 ++++++++++-----
 gitk-git/po/bg.po    |  3 +++
 gitk-git/po/ca.po    |  3 +++
 gitk-git/po/de.po    |  3 +++
 gitk-git/po/es.po    |  3 +++
 gitk-git/po/fr.po    |  3 +++
 gitk-git/po/hu.po    |  3 +++
 gitk-git/po/it.po    |  3 +++
 gitk-git/po/ja.po    |  3 +++
 gitk-git/po/pt_br.po |  3 +++
 gitk-git/po/pt_pt.po |  3 +++
 gitk-git/po/ru.po    |  3 +++
 gitk-git/po/sv.po    |  3 +++
 gitk-git/po/ta.po    |  3 +++
 gitk-git/po/vi.po    |  3 +++
 gitk-git/po/zh_cn.po |  3 +++
 16 files changed, 55 insertions(+), 5 deletions(-)

diff --git a/gitk-git/gitk b/gitk-git/gitk
index 9506739c50..5d9c781778 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 this commit with -x" command {cherrypick 1}}
         {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 {{withx 0}} {
     global rowmenuid curview
     global mainhead mainheadid
     global gitdir
@@ -9898,7 +9899,11 @@ 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]} {
+        set xopt ""
+    if {$withx} {
+        set xopt " -x"
+    }
+    if {[catch {safe_exec [list sh -c "git cherry-pick -r$xopt $rowmenuid 2>&1"]} err]} {
         notbusy cherrypick
         if {[regexp -line \
                  {Entry '(.*)' (would be overwritten by merge|not uptodate)} \
diff --git a/gitk-git/po/bg.po b/gitk-git/po/bg.po
index 3521fdbeb4..15615fc1fa 100644
--- a/gitk-git/po/bg.po
+++ b/gitk-git/po/bg.po
@@ -223,6 +223,9 @@ msgstr "Създаване на нов клон"
 
 msgid "Cherry-pick this commit"
 msgstr "Отбиране на това подаване"
+msgid "Cherry-pick this commit with -x"
+msgstr ""
+
 
 msgid "Reset HEAD branch to here"
 msgstr "Привеждане на върха на клона към текущото подаване"
diff --git a/gitk-git/po/ca.po b/gitk-git/po/ca.po
index d588d0990f..b8510407ec 100644
--- a/gitk-git/po/ca.po
+++ b/gitk-git/po/ca.po
@@ -219,6 +219,9 @@ msgstr "Crea una branca nova"
 
 msgid "Cherry-pick this commit"
 msgstr "Recull aquesta comissió com a cirera"
+msgid "Cherry-pick this commit with -x"
+msgstr ""
+
 
 msgid "Reset HEAD branch to here"
 msgstr "Restableix la branca HEAD aquí"
diff --git a/gitk-git/po/de.po b/gitk-git/po/de.po
index fea18fa16e..ab85962dc6 100644
--- a/gitk-git/po/de.po
+++ b/gitk-git/po/de.po
@@ -217,6 +217,9 @@ msgstr "Neuen Zweig erstellen"
 
 msgid "Cherry-pick this commit"
 msgstr "Diese Version pflücken"
+msgid "Cherry-pick this commit with -x"
+msgstr ""
+
 
 msgid "Reset HEAD branch to here"
 msgstr "HEAD-Zweig auf diese Version zurücksetzen"
diff --git a/gitk-git/po/es.po b/gitk-git/po/es.po
index 881738e9e6..c5edd28860 100644
--- a/gitk-git/po/es.po
+++ b/gitk-git/po/es.po
@@ -224,6 +224,9 @@ msgstr "Crear nueva rama"
 
 msgid "Cherry-pick this commit"
 msgstr "Añadir esta revisión a la rama actual (cherry-pick)"
+msgid "Cherry-pick this commit with -x"
+msgstr ""
+
 
 msgid "Reset HEAD branch to here"
 msgstr "Traer la rama HEAD aquí"
diff --git a/gitk-git/po/fr.po b/gitk-git/po/fr.po
index f1c54b6b6a..3aa4ac0049 100644
--- a/gitk-git/po/fr.po
+++ b/gitk-git/po/fr.po
@@ -223,6 +223,9 @@ msgstr "Créer une nouvelle branche"
 
 msgid "Cherry-pick this commit"
 msgstr "Cueillir (cherry-pick) ce commit"
+msgid "Cherry-pick this commit with -x"
+msgstr ""
+
 
 msgid "Reset HEAD branch to here"
 msgstr "Réinitialiser la branche HEAD vers cet état"
diff --git a/gitk-git/po/hu.po b/gitk-git/po/hu.po
index 9ab3f9617d..0160330bbf 100644
--- a/gitk-git/po/hu.po
+++ b/gitk-git/po/hu.po
@@ -216,6 +216,9 @@ msgstr "Új branch készítése"
 
 msgid "Cherry-pick this commit"
 msgstr "Cherry-pick erre a commitra"
+msgid "Cherry-pick this commit with -x"
+msgstr ""
+
 
 msgid "Reset HEAD branch to here"
 msgstr "HEAD branch újraindítása ide"
diff --git a/gitk-git/po/it.po b/gitk-git/po/it.po
index aa34a34280..1b013c9120 100644
--- a/gitk-git/po/it.po
+++ b/gitk-git/po/it.po
@@ -217,6 +217,9 @@ msgstr "Crea un nuovo ramo"
 
 msgid "Cherry-pick this commit"
 msgstr "Porta questa revisione in cima al ramo attuale"
+msgid "Cherry-pick this commit with -x"
+msgstr ""
+
 
 msgid "Reset HEAD branch to here"
 msgstr "Aggiorna il ramo HEAD a questa revisione"
diff --git a/gitk-git/po/ja.po b/gitk-git/po/ja.po
index 2c40b76dc0..bfc0754f27 100644
--- a/gitk-git/po/ja.po
+++ b/gitk-git/po/ja.po
@@ -223,6 +223,9 @@ msgstr "新規ブランチ生成"
 
 msgid "Cherry-pick this commit"
 msgstr "このコミットをチェリーピックする"
+msgid "Cherry-pick this commit with -x"
+msgstr ""
+
 
 msgid "Reset HEAD branch to here"
 msgstr "ブランチのHEADをここにリセットする"
diff --git a/gitk-git/po/pt_br.po b/gitk-git/po/pt_br.po
index e78fb26a2e..968a2fd328 100644
--- a/gitk-git/po/pt_br.po
+++ b/gitk-git/po/pt_br.po
@@ -218,6 +218,9 @@ msgstr "Criar novo ramo"
 
 msgid "Cherry-pick this commit"
 msgstr "Fazer cherry-pick desta revisão"
+msgid "Cherry-pick this commit with -x"
+msgstr ""
+
 
 msgid "Reset HEAD branch to here"
 msgstr "Redefinir HEAD para cá"
diff --git a/gitk-git/po/pt_pt.po b/gitk-git/po/pt_pt.po
index 66d3159d47..db71579365 100644
--- a/gitk-git/po/pt_pt.po
+++ b/gitk-git/po/pt_pt.po
@@ -220,6 +220,9 @@ msgstr "Criar novo ramo"
 
 msgid "Cherry-pick this commit"
 msgstr "Efetuar cherry-pick deste commit"
+msgid "Cherry-pick this commit with -x"
+msgstr ""
+
 
 msgid "Reset HEAD branch to here"
 msgstr "Repor ramo HEAD para aqui"
diff --git a/gitk-git/po/ru.po b/gitk-git/po/ru.po
index e102fb7200..7a3e1d73d0 100644
--- a/gitk-git/po/ru.po
+++ b/gitk-git/po/ru.po
@@ -226,6 +226,9 @@ msgstr "Создать ветку"
 
 msgid "Cherry-pick this commit"
 msgstr "Копировать этот коммит в текущую ветку"
+msgid "Cherry-pick this commit with -x"
+msgstr ""
+
 
 msgid "Reset HEAD branch to here"
 msgstr "Установить HEAD на этот коммит"
diff --git a/gitk-git/po/sv.po b/gitk-git/po/sv.po
index c9290625c0..7dbae72847 100644
--- a/gitk-git/po/sv.po
+++ b/gitk-git/po/sv.po
@@ -223,6 +223,9 @@ msgstr "Skapa ny gren"
 
 msgid "Cherry-pick this commit"
 msgstr "Plocka denna incheckning"
+msgid "Cherry-pick this commit with -x"
+msgstr ""
+
 
 msgid "Reset HEAD branch to here"
 msgstr "Återställ HEAD-grenen hit"
diff --git a/gitk-git/po/ta.po b/gitk-git/po/ta.po
index 9b9176a4aa..ddf8b12e89 100644
--- a/gitk-git/po/ta.po
+++ b/gitk-git/po/ta.po
@@ -220,6 +220,9 @@ msgstr "புதிய கிளையை உருவாக்கு"
 
 msgid "Cherry-pick this commit"
 msgstr "கனி-எடு இந்த உறுதிமொழி"
+msgid "Cherry-pick this commit with -x"
+msgstr ""
+
 
 msgid "Reset HEAD branch to here"
 msgstr "தலை கிளையை இங்கே மீட்டமை"
diff --git a/gitk-git/po/vi.po b/gitk-git/po/vi.po
index 52c9d09a09..81e031d96d 100644
--- a/gitk-git/po/vi.po
+++ b/gitk-git/po/vi.po
@@ -217,6 +217,9 @@ msgstr "Tạo nhánh mới"
 
 msgid "Cherry-pick this commit"
 msgstr "Cherry-pick lần chuyển giao này"
+msgid "Cherry-pick this commit with -x"
+msgstr ""
+
 
 msgid "Reset HEAD branch to here"
 msgstr "Đặt lại HEAD của nhánh vào đây"
diff --git a/gitk-git/po/zh_cn.po b/gitk-git/po/zh_cn.po
index 71a9878318..97dd066b49 100644
--- a/gitk-git/po/zh_cn.po
+++ b/gitk-git/po/zh_cn.po
@@ -214,6 +214,9 @@ msgstr "创建新分支"
 
 msgid "Cherry-pick this commit"
 msgstr "在此提交运用补丁(cherry-pick)命令"
+msgid "Cherry-pick this commit with -x"
+msgstr ""
+
 
 msgid "Reset HEAD branch to here"
 msgstr "将分支头(HEAD)重置到此处"
-- 
2.51.0


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

* Re: [PATCH] gitk: add cherry-pick -x context menu action
  2026-10-24  9:40 [PATCH] gitk: add cherry-pick -x context menu action Ralf Habacker
@ 2026-10-24 15:52 ` Johannes Sixt
  2026-10-24 16:50   ` Kristoffer Haugsbakk
  0 siblings, 1 reply; 3+ messages in thread
From: Johannes Sixt @ 2026-10-24 15:52 UTC (permalink / raw)
  To: Ralf Habacker; +Cc: git

Please paste the contents of the format-patch output into the email; do
not send it as attachment. See the format-patch man page[1] how to set
up a mail client in a way that does not mangle the patch text.

[1] https://git-scm.com/docs/git-format-patch#_mua_specific_hints

Am 24.10.26 um 11:40 schrieb Ralf Habacker:
> For example, this command is very useful for cherry-picking
> commits into a stable branch using a reference—something that

We need an en-dash or em-dash (two or three dashes) between "reference"
and "something" to give the sentence the correct meaning.

> otherwise can only be done from the command line.
> 

Personally, I use cherry-pick -x so rarely that I have no problem going
to the command line for those cases. Since the context menu is already
very long, I am hesitant to add a small variation of a command that is
already present (and very useful).

Are others interested in this feature?

Below some comments on the implementation just in case there are.

> Signed-off-by: Ralf Habacker <ralf.habacker@freenet.de>
> ---
>  gitk-git/gitk        | 15 ++++++++++-----
>  gitk-git/po/bg.po    |  3 +++
>  gitk-git/po/ca.po    |  3 +++
>  gitk-git/po/de.po    |  3 +++
>  gitk-git/po/es.po    |  3 +++
>  gitk-git/po/fr.po    |  3 +++
>  gitk-git/po/hu.po    |  3 +++
>  gitk-git/po/it.po    |  3 +++
>  gitk-git/po/ja.po    |  3 +++
>  gitk-git/po/pt_br.po |  3 +++
>  gitk-git/po/pt_pt.po |  3 +++
>  gitk-git/po/ru.po    |  3 +++
>  gitk-git/po/sv.po    |  3 +++
>  gitk-git/po/ta.po    |  3 +++
>  gitk-git/po/vi.po    |  3 +++
>  gitk-git/po/zh_cn.po |  3 +++

Please do not edit the translation files.

>  16 files changed, 55 insertions(+), 5 deletions(-)
> 
> diff --git a/gitk-git/gitk b/gitk-git/gitk
> index 9506739c50..5d9c781778 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 this commit with -x" command {cherrypick 1}}

We are in a UI here. Avoid jargon. ("What is -x??") How about:

	"Cherry-pick with cross-reference"

>          {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 {{withx 0}} {

If you make the default value of the parameter "-r", then the new caller
can just pass "-x" and we do not need the conditional below. (Also
rename the parameter.)

>      global rowmenuid curview
>      global mainhead mainheadid
>      global gitdir
> @@ -9898,7 +9899,11 @@ 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]} {
> +        set xopt ""
> +    if {$withx} {
> +        set xopt " -x"
> +    }
> +    if {[catch {safe_exec [list sh -c "git cherry-pick -r$xopt $rowmenuid 2>&1"]} err]} {

-r and -x are opposites. While the last one wins, it would be great if
the one option that is not used would not remain in the command.

>          notbusy cherrypick
>          if {[regexp -line \
>                   {Entry '(.*)' (would be overwritten by merge|not uptodate)} \

-- Hannes


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

* Re: [PATCH] gitk: add cherry-pick -x context menu action
  2026-10-24 15:52 ` Johannes Sixt
@ 2026-10-24 16:50   ` Kristoffer Haugsbakk
  0 siblings, 0 replies; 3+ messages in thread
From: Kristoffer Haugsbakk @ 2026-10-24 16:50 UTC (permalink / raw)
  To: Johannes Sixt, Ralf Habacker; +Cc: git

On Sat, Oct 24, 2026, at 17:52, Johannes Sixt wrote:
>[snip]
>
> Am 24.10.26 um 11:40 schrieb Ralf Habacker:
>> For example, this command is very useful for cherry-picking
>> commits into a stable branch using a reference—something that
>
> We need an en-dash or em-dash (two or three dashes) between "reference"
> and "something" to give the sentence the correct meaning.

That is an em-dash. I guess 2–3 hyphens are
wanted instead since they take up the expected
amount of space in a monospace font.

Personally, I think a comma would work
too in that context.

>[snip]
> -- Hannes

Sent from mobile again

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

end of thread, other threads:[~2026-10-24 16:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-24  9:40 [PATCH] gitk: add cherry-pick -x context menu action Ralf Habacker
2026-10-24 15:52 ` Johannes Sixt
2026-10-24 16:50   ` Kristoffer Haugsbakk

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