From: "Ulrich Hornung via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Ulrich Hornung <hornunguli@gmx.de>, Ulrich Hornung <hornunguli@gmx.de>
Subject: [PATCH] add ctx menu for tags, impl "remove tag" and "copy tag name"
Date: Fri, 12 Jan 2024 21:48:34 +0000 [thread overview]
Message-ID: <pull.1629.git.1705096114752.gitgitgadget@gmail.com> (raw)
From: Ulrich Hornung <hornunguli@gmx.de>
Signed-off-by: Ulrich Hornung <hornunguli@gmx.de>
---
gitk: add ctx menu for tags, impl "remove tag" and "copy tag name"
Hello,
I'm currently using git gui and gitk quite strongly. It happens to me
once in a while that I accidentially create a tag instead of a new
branch when using the GUI of gitk for this. Sadly, in this situation I
needed to go to the console to remove this tag again, because the latest
version of gitk doesn't have a "remove tag" button.
Lukily I was able to implement that button (and the copy name button) by
myself. I would be happy if you could integrate the new feature into the
official sources.
Bildschirmfoto vom 2024-01-01 17-26-07
[https://github.com/gitgitgadget/git/assets/252806/079c28dd-b4a0-486c-ad1e-27f7f2fde814]
Thanks.
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1629%2Fcre4ture%2Ffeature%2Ftag_ctx_menu_remove_tag-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1629/cre4ture/feature/tag_ctx_menu_remove_tag-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/1629
gitk-git/gitk | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 66 insertions(+), 1 deletion(-)
diff --git a/gitk-git/gitk b/gitk-git/gitk
index 7a087f123d7..7a70e1fba31 100755
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -1894,6 +1894,21 @@ proc removehead {id name} {
unset headids($name)
}
+# update things when a tag has been removed
+proc removetag {id name} {
+ global tagids idtags
+
+ if {$idtags($id) eq $name} {
+ unset idtags($id)
+ } else {
+ set i [lsearch -exact $idtags($id) $name]
+ if {$i >= 0} {
+ set idtags($id) [lreplace $idtags($id) $i $i]
+ }
+ }
+ unset tagids($name)
+}
+
proc ttk_toplevel {w args} {
global use_ttk
eval [linsert $args 0 ::toplevel $w]
@@ -2096,7 +2111,7 @@ proc makewindow {} {
global uifgcolor uifgdisabledcolor
global filesepbgcolor filesepfgcolor
global mergecolors foundbgcolor currentsearchhitbgcolor
- global headctxmenu progresscanv progressitem progresscoords statusw
+ global headctxmenu tagctxmenu progresscanv progressitem progresscoords statusw
global fprogitem fprogcoord lastprogupdate progupdatepending
global rprogitem rprogcoord rownumsel numcommits
global have_tk85 use_ttk NS
@@ -2705,6 +2720,13 @@ proc makewindow {} {
}
$headctxmenu configure -tearoff 0
+ set tagctxmenu .tagctxmenu
+ makemenu $tagctxmenu {
+ {mc "Remove this tag" command rmtag}
+ {mc "Copy tag name" command {clipboard clear; clipboard append $tagmenutag}}
+ }
+ $tagctxmenu configure -tearoff 0
+
global flist_menu
set flist_menu .flistctxmenu
makemenu $flist_menu {
@@ -6701,6 +6723,7 @@ proc drawtags {id x xt y1} {
-font $font -tags [list tag.$id text]]
if {$ntags >= 0} {
$canv bind $t <1> $tagclick
+ $canv bind $t $ctxbut [list tagmenu %X %Y $id $tag_quoted]
} elseif {$nheads >= 0} {
$canv bind $t $ctxbut [list headmenu %X %Y $id $tag_quoted]
}
@@ -9938,6 +9961,20 @@ proc headmenu {x y id head} {
tk_popup $headctxmenu $x $y
}
+# context menu for a tag
+proc tagmenu {x y id head} {
+ global tagmenuid tagmenutag tagctxmenu
+
+ stopfinding
+ set tagmenuid $id
+ set tagmenutag $head
+ array set state {0 normal 1 normal}
+ foreach i {0 1} {
+ $tagctxmenu entryconfigure $i -state $state($i)
+ }
+ tk_popup $tagctxmenu $x $y
+}
+
proc cobranch {} {
global headmenuid headmenuhead headids
global showlocalchanges
@@ -10042,6 +10079,27 @@ proc rmbranch {} {
run refill_reflist
}
+proc rmtag {} {
+ global tagmenuid tagmenutag
+
+ set tag $tagmenutag
+ set id $tagmenuid
+
+ nowbusy rmtag
+ update
+ if {[catch {exec git tag -d $tag} err]} {
+ notbusy rmtag
+ error_popup $err
+ return
+ }
+ removetag $id $tag
+ removedtag $id $tag
+ redrawtags $id
+ notbusy rmtag
+ dispneartags 0
+ run refill_reflist
+}
+
# Display a list of tags and heads
proc showrefs {} {
global showrefstop bgcolor fgcolor selectbgcolor NS
@@ -11273,6 +11331,13 @@ proc removedhead {hid head} {
unset -nocomplain cached_dheads
}
+proc removedtag {hid head} {
+ global cached_dtags cached_atags
+
+ unset -nocomplain cached_dtags
+ unset -nocomplain cached_atags
+}
+
proc movedhead {hid head} {
global arcnos arcout cached_dheads
base-commit: a26002b62827b89a19b1084bd75d9371d565d03c
--
gitgitgadget
reply other threads:[~2024-01-12 21:48 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=pull.1629.git.1705096114752.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=git@vger.kernel.org \
--cc=hornunguli@gmx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.