{"thread":{"id":"60740","subject":"[PATCH] add ctx menu for tags, impl \"remove tag\" and \"copy tag name\"","startedAt":"2024-01-12T21:48:38Z","lastAt":"2024-01-12T21:48:38Z","messageCount":1,"participants":["Ulrich Hornung via GitGitGadget"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"486738","messageId":"pull.1629.git.1705096114752.gitgitgadget@gmail.com","threadId":"60740","inReplyTo":null,"subject":"[PATCH] add ctx menu for tags, impl \"remove tag\" and \"copy tag name\"","fromName":"Ulrich Hornung via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2024-01-12T21:48:34Z","receivedAt":"2024-01-12T21:48:38Z","isPatch":true,"sender":{"key":"name:Ulrich Hornung","avatar":null},"body":"From: Ulrich Hornung <hornunguli@gmx.de>\n\nSigned-off-by: Ulrich Hornung <hornunguli@gmx.de>\n---\n    gitk: add ctx menu for tags, impl \"remove tag\" and \"copy tag name\"\n    \n    Hello,\n    \n    I'm currently using git gui and gitk quite strongly. It happens to me\n    once in a while that I accidentially create a tag instead of a new\n    branch when using the GUI of gitk for this. Sadly, in this situation I\n    needed to go to the console to remove this tag again, because the latest\n    version of gitk doesn't have a \"remove tag\" button.\n    \n    Lukily I was able to implement that button (and the copy name button) by\n    myself. I would be happy if you could integrate the new feature into the\n    official sources.\n    \n    Bildschirmfoto vom 2024-01-01 17-26-07\n    [https://github.com/gitgitgadget/git/assets/252806/079c28dd-b4a0-486c-ad1e-27f7f2fde814]\n    \n    Thanks.\n\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-1629%2Fcre4ture%2Ffeature%2Ftag_ctx_menu_remove_tag-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1629/cre4ture/feature/tag_ctx_menu_remove_tag-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/1629\n\n gitk-git/gitk | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++-\n 1 file changed, 66 insertions(+), 1 deletion(-)\n\ndiff --git a/gitk-git/gitk b/gitk-git/gitk\nindex 7a087f123d7..7a70e1fba31 100755\n--- a/gitk-git/gitk\n+++ b/gitk-git/gitk\n@@ -1894,6 +1894,21 @@ proc removehead {id name} {\n     unset headids($name)\n }\n \n+# update things when a tag has been removed\n+proc removetag {id name} {\n+    global tagids idtags\n+\n+    if {$idtags($id) eq $name} {\n+        unset idtags($id)\n+    } else {\n+        set i [lsearch -exact $idtags($id) $name]\n+        if {$i >= 0} {\n+            set idtags($id) [lreplace $idtags($id) $i $i]\n+        }\n+    }\n+    unset tagids($name)\n+}\n+\n proc ttk_toplevel {w args} {\n     global use_ttk\n     eval [linsert $args 0 ::toplevel $w]\n@@ -2096,7 +2111,7 @@ proc makewindow {} {\n     global uifgcolor uifgdisabledcolor\n     global filesepbgcolor filesepfgcolor\n     global mergecolors foundbgcolor currentsearchhitbgcolor\n-    global headctxmenu progresscanv progressitem progresscoords statusw\n+    global headctxmenu tagctxmenu progresscanv progressitem progresscoords statusw\n     global fprogitem fprogcoord lastprogupdate progupdatepending\n     global rprogitem rprogcoord rownumsel numcommits\n     global have_tk85 use_ttk NS\n@@ -2705,6 +2720,13 @@ proc makewindow {} {\n     }\n     $headctxmenu configure -tearoff 0\n \n+    set tagctxmenu .tagctxmenu\n+    makemenu $tagctxmenu {\n+        {mc \"Remove this tag\" command rmtag}\n+        {mc \"Copy tag name\" command {clipboard clear; clipboard append $tagmenutag}}\n+    }\n+    $tagctxmenu configure -tearoff 0\n+\n     global flist_menu\n     set flist_menu .flistctxmenu\n     makemenu $flist_menu {\n@@ -6701,6 +6723,7 @@ proc drawtags {id x xt y1} {\n                    -font $font -tags [list tag.$id text]]\n         if {$ntags >= 0} {\n             $canv bind $t <1> $tagclick\n+            $canv bind $t $ctxbut [list tagmenu %X %Y $id $tag_quoted]\n         } elseif {$nheads >= 0} {\n             $canv bind $t $ctxbut [list headmenu %X %Y $id $tag_quoted]\n         }\n@@ -9938,6 +9961,20 @@ proc headmenu {x y id head} {\n     tk_popup $headctxmenu $x $y\n }\n \n+# context menu for a tag\n+proc tagmenu {x y id head} {\n+    global tagmenuid tagmenutag tagctxmenu\n+\n+    stopfinding\n+    set tagmenuid $id\n+    set tagmenutag $head\n+    array set state {0 normal 1 normal}\n+    foreach i {0 1} {\n+        $tagctxmenu entryconfigure $i -state $state($i)\n+    }\n+    tk_popup $tagctxmenu $x $y\n+}\n+\n proc cobranch {} {\n     global headmenuid headmenuhead headids\n     global showlocalchanges\n@@ -10042,6 +10079,27 @@ proc rmbranch {} {\n     run refill_reflist\n }\n \n+proc rmtag {} {\n+    global tagmenuid tagmenutag\n+\n+    set tag $tagmenutag\n+    set id $tagmenuid\n+\n+    nowbusy rmtag\n+    update\n+    if {[catch {exec git tag -d $tag} err]} {\n+        notbusy rmtag\n+        error_popup $err\n+        return\n+    }\n+    removetag $id $tag\n+    removedtag $id $tag\n+    redrawtags $id\n+    notbusy rmtag\n+    dispneartags 0\n+    run refill_reflist\n+}\n+\n # Display a list of tags and heads\n proc showrefs {} {\n     global showrefstop bgcolor fgcolor selectbgcolor NS\n@@ -11273,6 +11331,13 @@ proc removedhead {hid head} {\n     unset -nocomplain cached_dheads\n }\n \n+proc removedtag {hid head} {\n+    global cached_dtags cached_atags\n+\n+    unset -nocomplain cached_dtags\n+    unset -nocomplain cached_atags\n+}\n+\n proc movedhead {hid head} {\n     global arcnos arcout cached_dheads\n \n\nbase-commit: a26002b62827b89a19b1084bd75d9371d565d03c\n-- \ngitgitgadget\n"}]}