# [PATCH] gitk tag delete/rename support

7 messages from 2012-11-23 to 2013-01-02. Participants: Leon KUKOVEC, Ramkumar Ramachandra, Junio C Hamano, Paul Mackerras.
Thread: https://gitlist.dev/t/32172

## Leon KUKOVEC, 2012-11-23 05:51

Subject: [PATCH] gitk tag delete/rename support
Message-ID: <1353649899-15641-1-git-send-email-leon.kukovec@gmail.com>
URL: https://gitlist.dev/e/1353649899-15641-1-git-send-email-leon.kukovec%40gmail.com

```
---
 gitk-git/gitk |  154 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 154 insertions(+)

diff --git a/gitk-git/gitk b/gitk-git/gitk
index 17ba10a..12a7139 100755
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -1981,6 +1981,7 @@ proc makewindow {} {
     global have_tk85 use_ttk NS
     global git_version
     global worddiff
+    global tagctxmenu
 
     # The "mc" arguments here are purely so that xgettext
     # sees the following string as needing to be translated
@@ -2526,6 +2527,13 @@ proc makewindow {} {
 	{mc "Run git gui blame on this line" command {external_blame_diff}}
     }
     $diff_menu configure -tearoff 0
+
+    set tagctxmenu .tagctxmenu
+    makemenu $tagctxmenu {
+	{mc "Rename this tag" command mvtag}
+	{mc "Delete this tag" command rmtag}
+    }
+    $tagctxmenu configure -tearoff 0
 }
 
 # Windows sends all mouse wheel events to the current focused window, not
@@ -6345,6 +6353,7 @@ proc drawtags {id x xt y1} {
 		   -font $font -tags [list tag.$id text]]
 	if {$ntags >= 0} {
 	    $canv bind $t <1> [list showtag $tag_quoted 1]
+	    $canv bind $t $ctxbut [list showtagmenu %X %Y $id $tag_quoted]
 	} elseif {$nheads >= 0} {
 	    $canv bind $t $ctxbut [list headmenu %X %Y $id $tag_quoted]
 	}
@@ -8857,6 +8866,113 @@ proc domktag {} {
     return 1
 }
 
+proc mvtag {} {
+    global mvtagtop
+    global tagmenuid tagmenutag tagctxmenu maintag NS
+    global mvtagtag
+
+    set mvtagtag $tagmenutag
+    set top .movetag
+    set mvtagtop $top
+    catch {destroy $top}
+    ttk_toplevel $top
+    make_transient $top .
+
+    ${NS}::label $top.msg -text [mc "Enter a new tag name:"]
+    ${NS}::entry $top.tag -width 60 -textvariable mvtagtag
+
+    grid $top.msg -sticky w -row 0 -column 0
+    grid $top.tag -sticky w -row 0 -column 1
+
+    ${NS}::frame $top.buts
+    ${NS}::button $top.buts.gen -text [mc "Rename"] -command mvtaggo
+    ${NS}::button $top.buts.can -text [mc "Cancel"] -command mvtagcan
+    bind $top <Key-Return> mvtaggo
+    bind $top <Key-Escape> mvtagcan
+    grid $top.buts.gen $top.buts.can
+    grid columnconfigure $top.buts 0 -weight 1 -uniform a
+    grid columnconfigure $top.buts 1 -weight 1 -uniform a
+    grid $top.buts - -pady 10 -sticky ew
+}
+
+proc domvtag {} {
+    global mvtagtop env tagids idtags tagmenutag tagmenuid mvtagtag
+
+    set tag $mvtagtag
+    set id $tagmenuid
+
+    # add tag
+    # XXX: reuse domktag including keeping comment from the original tag.
+    if {[catch {
+        exec git tag $tag $id
+    } err]} {
+        error_popup "[mc "Error renaming tag:"] $err" $mvtagtop
+        return 0
+    }
+
+    # delete old tag, content stored in $tagmenutag and $tagmenuid
+    dormtag
+
+    set tagids($tag) $id
+    lappend idtags($id) $tag
+    redrawtags $id
+    addedtag $id
+    dispneartags 0
+    run refill_reflist
+    return 1
+}
+
+proc rmtag {} {
+    global rmtagtop
+    global tagmenuid tagmenutag tagctxmenu maintag NS
+
+    set top .maketag
+    set rmtagtop $top
+    catch {destroy $top}
+    ttk_toplevel $top
+    make_transient $top .
+    ${NS}::label $top.title -text [mc "Delete tag"]
+    grid $top.title - -pady 10
+
+    ${NS}::label $top.msg -text [mc "You are about to delete a tag"]
+    ${NS}::label $top.tagname -foreground Red -text [mc "$tagmenutag"]
+    grid $top.msg -sticky w -row 0 -column 0
+    grid $top.tagname -sticky w -row 0 -column 1
+
+    ${NS}::frame $top.buts
+    ${NS}::button $top.buts.gen -text [mc "Delete"] -command rmtaggo
+    ${NS}::button $top.buts.can -text [mc "Cancel"] -command rmtagcan
+    bind $top <Key-Return> rmtaggo
+    bind $top <Key-Escape> rmtagcan
+    grid $top.buts.gen $top.buts.can
+    grid columnconfigure $top.buts 0 -weight 1 -uniform a
+    grid columnconfigure $top.buts 1 -weight 1 -uniform a
+    grid $top.buts - -pady 10 -sticky ew
+}
+
+proc dormtag {} {
+    global rmtagtop env tagids idtags tagmenutag tagmenuid
+
+    set tag $tagmenutag
+    set id $tagmenuid
+
+    if {[catch {
+        exec git tag -d $tag
+    } err]} {
+        error_popup "[mc "Error deleting tag:"] $err" $rmtagtop
+        return 0
+    }
+
+    unset tagids($tag)
+    set idx [lsearch $idtags($id) $tag]
+    set idtags($id) [lreplace $idtags($id) $idx $idx]
+
+    redrawtags $id
+    dispneartags 0
+    run refill_reflist
+    return 1
+}
+
 proc redrawtags {id} {
     global canv linehtag idpos currentid curview cmitlisted markedid
     global canvxmax iddrawn circleitem mainheadid circlecolors
@@ -8900,6 +9016,30 @@ proc mktaggo {} {
     mktagcan
 }
 
+proc rmtagcan {} {
+    global rmtagtop
+
+    catch {destroy $rmtagtop}
+    unset rmtagtop
+}
+
+proc rmtaggo {} {
+    if {![dormtag]} return
+    rmtagcan
+}
+
+proc mvtagcan {} {
+    global mvtagtop
+
+    catch {destroy $mvtagtop}
+    unset mvtagtop
+}
+
+proc mvtaggo {} {
+    if {![domvtag]} return
+    mvtagcan
+}
+
 proc writecommit {} {
     global rowmenuid wrcomtop commitinfo wrcomcmd NS
 
@@ -9214,6 +9354,20 @@ proc headmenu {x y id head} {
     tk_popup $headctxmenu $x $y
 }
 
+# context menu for a tag
+proc showtagmenu {x y id tag} {
+    global tagmenuid tagmenutag tagctxmenu maintag
+
+    stopfinding
+    set tagmenuid $id
+    set tagmenutag $tag
+    set state normal
+
+    $tagctxmenu entryconfigure 0 -state normal
+    $tagctxmenu entryconfigure 1 -state normal
+    tk_popup $tagctxmenu $x $y
+}
+
 proc cobranch {} {
     global headmenuid headmenuhead headids
     global showlocalchanges
-- 
1.7.9.5

```

## Ramkumar Ramachandra, 2012-11-23 12:38

Subject: Re: [PATCH] gitk tag delete/rename support
Message-ID: <CALkWK0mZrqQAg=dKGeFA_Lg9fnApBW84=KQ-XPDCLZV7ev_S=A@mail.gmail.com>
URL: https://gitlist.dev/e/CALkWK0mZrqQAg%3DdKGeFA_Lg9fnApBW84%3DKQ-XPDCLZV7ev_S%3DA%40mail.gmail.com
In-Reply-To: <1353649899-15641-1-git-send-email-leon.kukovec@gmail.com>

```
Leon KUKOVEC wrote:
> ---
> [...]

Commit message and signoff?

Ram

```

## Leon KUKOVEC, 2012-11-23 16:41

Subject: [PATCH] gitk tag delete/rename support
Message-ID: <1353688894-2526-1-git-send-email-leon.kukovec@gmail.com>
URL: https://gitlist.dev/e/1353688894-2526-1-git-send-email-leon.kukovec%40gmail.com
In-Reply-To: <1353649899-15641-1-git-send-email-leon.kukovec@gmail.com>

```
Right clicking on a tag pops up a menu, which allows
tag to be renamed or deleted.

Signed-off-by: Leon KUKOVEC <leon.kukovec@gmail.com>
---
 gitk-git/gitk |  154 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 154 insertions(+)

diff --git a/gitk-git/gitk b/gitk-git/gitk
index d93bd99..38cc233 100755
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -2032,6 +2032,7 @@ proc makewindow {} {
     global have_tk85 use_ttk NS
     global git_version
     global worddiff
+    global tagctxmenu
 
     # The "mc" arguments here are purely so that xgettext
     # sees the following string as needing to be translated
@@ -2581,6 +2582,13 @@ proc makewindow {} {
 	{mc "Run git gui blame on this line" command {external_blame_diff}}
     }
     $diff_menu configure -tearoff 0
+
+    set tagctxmenu .tagctxmenu
+    makemenu $tagctxmenu {
+	{mc "Rename this tag" command mvtag}
+	{mc "Delete this tag" command rmtag}
+    }
+    $tagctxmenu configure -tearoff 0
 }
 
 # Windows sends all mouse wheel events to the current focused window, not
@@ -6400,6 +6408,7 @@ proc drawtags {id x xt y1} {
 		   -font $font -tags [list tag.$id text]]
 	if {$ntags >= 0} {
 	    $canv bind $t <1> [list showtag $tag_quoted 1]
+	    $canv bind $t $ctxbut [list showtagmenu %X %Y $id $tag_quoted]
 	} elseif {$nheads >= 0} {
 	    $canv bind $t $ctxbut [list headmenu %X %Y $id $tag_quoted]
 	}
@@ -8931,6 +8940,113 @@ proc domktag {} {
     return 1
 }
 
+proc mvtag {} {
+    global mvtagtop
+    global tagmenuid tagmenutag tagctxmenu maintag NS
+    global mvtagtag
+
+    set mvtagtag $tagmenutag
+    set top .movetag
+    set mvtagtop $top
+    catch {destroy $top}
+    ttk_toplevel $top
+    make_transient $top .
+
+    ${NS}::label $top.msg -text [mc "Enter a new tag name:"]
+    ${NS}::entry $top.tag -width 60 -textvariable mvtagtag
+
+    grid $top.msg -sticky w -row 0 -column 0
+    grid $top.tag -sticky w -row 0 -column 1
+
+    ${NS}::frame $top.buts
+    ${NS}::button $top.buts.gen -text [mc "Rename"] -command mvtaggo
+    ${NS}::button $top.buts.can -text [mc "Cancel"] -command mvtagcan
+    bind $top <Key-Return> mvtaggo
+    bind $top <Key-Escape> mvtagcan
+    grid $top.buts.gen $top.buts.can
+    grid columnconfigure $top.buts 0 -weight 1 -uniform a
+    grid columnconfigure $top.buts 1 -weight 1 -uniform a
+    grid $top.buts - -pady 10 -sticky ew
+}
+
+proc domvtag {} {
+    global mvtagtop env tagids idtags tagmenutag tagmenuid mvtagtag
+
+    set tag $mvtagtag
+    set id $tagmenuid
+
+    # add tag
+    # XXX: reuse domktag including keeping comment from the original tag.
+    if {[catch {
+        exec git tag $tag $id
+    } err]} {
+        error_popup "[mc "Error renaming tag:"] $err" $mvtagtop
+        return 0
+    }
+
+    # delete old tag, content stored in $tagmenutag and $tagmenuid
+    dormtag
+
+    set tagids($tag) $id
+    lappend idtags($id) $tag
+    redrawtags $id
+    addedtag $id
+    dispneartags 0
+    run refill_reflist
+    return 1
+}
+
+proc rmtag {} {
+    global rmtagtop
+    global tagmenuid tagmenutag tagctxmenu maintag NS
+
+    set top .maketag
+    set rmtagtop $top
+    catch {destroy $top}
+    ttk_toplevel $top
+    make_transient $top .
+    ${NS}::label $top.title -text [mc "Delete tag"]
+    grid $top.title - -pady 10
+
+    ${NS}::label $top.msg -text [mc "You are about to delete a tag"]
+    ${NS}::label $top.tagname -foreground Red -text [mc "$tagmenutag"]
+    grid $top.msg -sticky w -row 0 -column 0
+    grid $top.tagname -sticky w -row 0 -column 1
+
+    ${NS}::frame $top.buts
+    ${NS}::button $top.buts.gen -text [mc "Delete"] -command rmtaggo
+    ${NS}::button $top.buts.can -text [mc "Cancel"] -command rmtagcan
+    bind $top <Key-Return> rmtaggo
+    bind $top <Key-Escape> rmtagcan
+    grid $top.buts.gen $top.buts.can
+    grid columnconfigure $top.buts 0 -weight 1 -uniform a
+    grid columnconfigure $top.buts 1 -weight 1 -uniform a
+    grid $top.buts - -pady 10 -sticky ew
+}
+
+proc dormtag {} {
+    global rmtagtop env tagids idtags tagmenutag tagmenuid
+
+    set tag $tagmenutag
+    set id $tagmenuid
+
+    if {[catch {
+        exec git tag -d $tag
+    } err]} {
+        error_popup "[mc "Error deleting tag:"] $err" $rmtagtop
+        return 0
+    }
+
+    unset tagids($tag)
+    set idx [lsearch $idtags($id) $tag]
+    set idtags($id) [lreplace $idtags($id) $idx $idx]
+
+    redrawtags $id
+    dispneartags 0
+    run refill_reflist
+    return 1
+}
+
 proc redrawtags {id} {
     global canv linehtag idpos currentid curview cmitlisted markedid
     global canvxmax iddrawn circleitem mainheadid circlecolors
@@ -8974,6 +9090,30 @@ proc mktaggo {} {
     mktagcan
 }
 
+proc rmtagcan {} {
+    global rmtagtop
+
+    catch {destroy $rmtagtop}
+    unset rmtagtop
+}
+
+proc rmtaggo {} {
+    if {![dormtag]} return
+    rmtagcan
+}
+
+proc mvtagcan {} {
+    global mvtagtop
+
+    catch {destroy $mvtagtop}
+    unset mvtagtop
+}
+
+proc mvtaggo {} {
+    if {![domvtag]} return
+    mvtagcan
+}
+
 proc writecommit {} {
     global rowmenuid wrcomtop commitinfo wrcomcmd NS
 
@@ -9288,6 +9428,20 @@ proc headmenu {x y id head} {
     tk_popup $headctxmenu $x $y
 }
 
+# context menu for a tag
+proc showtagmenu {x y id tag} {
+    global tagmenuid tagmenutag tagctxmenu maintag
+
+    stopfinding
+    set tagmenuid $id
+    set tagmenutag $tag
+    set state normal
+
+    $tagctxmenu entryconfigure 0 -state normal
+    $tagctxmenu entryconfigure 1 -state normal
+    tk_popup $tagctxmenu $x $y
+}
+
 proc cobranch {} {
     global headmenuid headmenuhead headids
     global showlocalchanges
-- 
1.7.9.5

```

## Junio C Hamano, 2012-11-25 06:26

Subject: Re: [PATCH] gitk tag delete/rename support
Message-ID: <7vzk26xkou.fsf@alter.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vzk26xkou.fsf%40alter.siamese.dyndns.org
In-Reply-To: <1353688894-2526-1-git-send-email-leon.kukovec@gmail.com>

```
Leon KUKOVEC <leon.kukovec@gmail.com> writes:

> Right clicking on a tag pops up a menu, which allows
> tag to be renamed or deleted.
>
> Signed-off-by: Leon KUKOVEC <leon.kukovec@gmail.com>
> ---

Thanks, but I prefer not to take patches to gitk-git/ directly;
could you prepare a patch against Paul's tree at


    git://ozlabs.org/~paulus/gitk

and send it in that direction (paulus@) instead?

>  gitk-git/gitk |  154 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 154 insertions(+)
>
> diff --git a/gitk-git/gitk b/gitk-git/gitk
> index d93bd99..38cc233 100755
> --- a/gitk-git/gitk
> +++ b/gitk-git/gitk
> @@ -2032,6 +2032,7 @@ proc makewindow {} {
>      global have_tk85 use_ttk NS
>      global git_version
>      global worddiff
> +    global tagctxmenu
>  
>      # The "mc" arguments here are purely so that xgettext
>      # sees the following string as needing to be translated
> @@ -2581,6 +2582,13 @@ proc makewindow {} {
>  	{mc "Run git gui blame on this line" command {external_blame_diff}}
>      }
>      $diff_menu configure -tearoff 0
> +
> +    set tagctxmenu .tagctxmenu
> +    makemenu $tagctxmenu {
> +	{mc "Rename this tag" command mvtag}
> +	{mc "Delete this tag" command rmtag}
> +    }
> +    $tagctxmenu configure -tearoff 0
>  }
>  
>  # Windows sends all mouse wheel events to the current focused window, not
> @@ -6400,6 +6408,7 @@ proc drawtags {id x xt y1} {
>  		   -font $font -tags [list tag.$id text]]
>  	if {$ntags >= 0} {
>  	    $canv bind $t <1> [list showtag $tag_quoted 1]
> +	    $canv bind $t $ctxbut [list showtagmenu %X %Y $id $tag_quoted]
>  	} elseif {$nheads >= 0} {
>  	    $canv bind $t $ctxbut [list headmenu %X %Y $id $tag_quoted]
>  	}
> @@ -8931,6 +8940,113 @@ proc domktag {} {
>      return 1
>  }
>  
> +proc mvtag {} {
> +    global mvtagtop
> +    global tagmenuid tagmenutag tagctxmenu maintag NS
> +    global mvtagtag
> +
> +    set mvtagtag $tagmenutag
> +    set top .movetag
> +    set mvtagtop $top
> +    catch {destroy $top}
> +    ttk_toplevel $top
> +    make_transient $top .
> +
> +    ${NS}::label $top.msg -text [mc "Enter a new tag name:"]
> +    ${NS}::entry $top.tag -width 60 -textvariable mvtagtag
> +
> +    grid $top.msg -sticky w -row 0 -column 0
> +    grid $top.tag -sticky w -row 0 -column 1
> +
> +    ${NS}::frame $top.buts
> +    ${NS}::button $top.buts.gen -text [mc "Rename"] -command mvtaggo
> +    ${NS}::button $top.buts.can -text [mc "Cancel"] -command mvtagcan
> +    bind $top <Key-Return> mvtaggo
> +    bind $top <Key-Escape> mvtagcan
> +    grid $top.buts.gen $top.buts.can
> +    grid columnconfigure $top.buts 0 -weight 1 -uniform a
> +    grid columnconfigure $top.buts 1 -weight 1 -uniform a
> +    grid $top.buts - -pady 10 -sticky ew
> +}
> +
> +proc domvtag {} {
> +    global mvtagtop env tagids idtags tagmenutag tagmenuid mvtagtag
> +
> +    set tag $mvtagtag
> +    set id $tagmenuid
> +
> +    # add tag
> +    # XXX: reuse domktag including keeping comment from the original tag.
> +    if {[catch {
> +        exec git tag $tag $id
> +    } err]} {
> +        error_popup "[mc "Error renaming tag:"] $err" $mvtagtop
> +        return 0
> +    }
> +
> +    # delete old tag, content stored in $tagmenutag and $tagmenuid
> +    dormtag
> +
> +    set tagids($tag) $id
> +    lappend idtags($id) $tag
> +    redrawtags $id
> +    addedtag $id
> +    dispneartags 0
> +    run refill_reflist
> +    return 1
> +}
> +
> +proc rmtag {} {
> +    global rmtagtop
> +    global tagmenuid tagmenutag tagctxmenu maintag NS
> +
> +    set top .maketag
> +    set rmtagtop $top
> +    catch {destroy $top}
> +    ttk_toplevel $top
> +    make_transient $top .
> +    ${NS}::label $top.title -text [mc "Delete tag"]
> +    grid $top.title - -pady 10
> +
> +    ${NS}::label $top.msg -text [mc "You are about to delete a tag"]
> +    ${NS}::label $top.tagname -foreground Red -text [mc "$tagmenutag"]
> +    grid $top.msg -sticky w -row 0 -column 0
> +    grid $top.tagname -sticky w -row 0 -column 1
> +
> +    ${NS}::frame $top.buts
> +    ${NS}::button $top.buts.gen -text [mc "Delete"] -command rmtaggo
> +    ${NS}::button $top.buts.can -text [mc "Cancel"] -command rmtagcan
> +    bind $top <Key-Return> rmtaggo
> +    bind $top <Key-Escape> rmtagcan
> +    grid $top.buts.gen $top.buts.can
> +    grid columnconfigure $top.buts 0 -weight 1 -uniform a
> +    grid columnconfigure $top.buts 1 -weight 1 -uniform a
> +    grid $top.buts - -pady 10 -sticky ew
> +}
> +
> +proc dormtag {} {
> +    global rmtagtop env tagids idtags tagmenutag tagmenuid
> +
> +    set tag $tagmenutag
> +    set id $tagmenuid
> +
> +    if {[catch {
> +        exec git tag -d $tag
> +    } err]} {
> +        error_popup "[mc "Error deleting tag:"] $err" $rmtagtop
> +        return 0
> +    }
> +
> +    unset tagids($tag)
> +    set idx [lsearch $idtags($id) $tag]
> +    set idtags($id) [lreplace $idtags($id) $idx $idx]
> +
> +    redrawtags $id
> +    dispneartags 0
> +    run refill_reflist
> +    return 1
> +}
> +
>  proc redrawtags {id} {
>      global canv linehtag idpos currentid curview cmitlisted markedid
>      global canvxmax iddrawn circleitem mainheadid circlecolors
> @@ -8974,6 +9090,30 @@ proc mktaggo {} {
>      mktagcan
>  }
>  
> +proc rmtagcan {} {
> +    global rmtagtop
> +
> +    catch {destroy $rmtagtop}
> +    unset rmtagtop
> +}
> +
> +proc rmtaggo {} {
> +    if {![dormtag]} return
> +    rmtagcan
> +}
> +
> +proc mvtagcan {} {
> +    global mvtagtop
> +
> +    catch {destroy $mvtagtop}
> +    unset mvtagtop
> +}
> +
> +proc mvtaggo {} {
> +    if {![domvtag]} return
> +    mvtagcan
> +}
> +
>  proc writecommit {} {
>      global rowmenuid wrcomtop commitinfo wrcomcmd NS
>  
> @@ -9288,6 +9428,20 @@ proc headmenu {x y id head} {
>      tk_popup $headctxmenu $x $y
>  }
>  
> +# context menu for a tag
> +proc showtagmenu {x y id tag} {
> +    global tagmenuid tagmenutag tagctxmenu maintag
> +
> +    stopfinding
> +    set tagmenuid $id
> +    set tagmenutag $tag
> +    set state normal
> +
> +    $tagctxmenu entryconfigure 0 -state normal
> +    $tagctxmenu entryconfigure 1 -state normal
> +    tk_popup $tagctxmenu $x $y
> +}
> +
>  proc cobranch {} {
>      global headmenuid headmenuhead headids
>      global showlocalchanges

```

## Leon KUKOVEC, 2012-11-25 16:02

Subject: Re: [PATCH] gitk tag delete/rename support
Message-ID: <CAOrOd9woDs16as+t-EReQ8NtXfYm9mpd0XaFFs-XL=pg+JK1Lw@mail.gmail.com>
URL: https://gitlist.dev/e/CAOrOd9woDs16as%2Bt-EReQ8NtXfYm9mpd0XaFFs-XL%3Dpg%2BJK1Lw%40mail.gmail.com
In-Reply-To: <7vzk26xkou.fsf@alter.siamese.dyndns.org>

```
Hi,

On Sun, Nov 25, 2012 at 7:26 AM, Junio C Hamano <gitster@pobox.com> wrote:
>
> Thanks, but I prefer not to take patches to gitk-git/ directly;
> could you prepare a patch against Paul's tree at
>
>
>     git://ozlabs.org/~paulus/gitk
>
> and send it in that direction (paulus@) instead?

No problem. Will do that.

--
Best Regards,
        Leon

```

## Leon KUKOVEC, 2012-11-25 19:05

Subject: [PATCH] gitk tag delete/rename support
Message-ID: <1353870345-3054-1-git-send-email-leon.kukovec@gmail.com>
URL: https://gitlist.dev/e/1353870345-3054-1-git-send-email-leon.kukovec%40gmail.com
In-Reply-To: <CAOrOd9woDs16as+t-EReQ8NtXfYm9mpd0XaFFs-XL=pg+JK1Lw@mail.gmail.com>

```
Right clicking on a tag pops up a menu, which allows
tag to be renamed or deleted.

Signed-off-by: Leon KUKOVEC <leon.kukovec@gmail.com>
---
 gitk-git/gitk |  154 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 154 insertions(+)

diff --git a/gitk-git/gitk b/gitk-git/gitk
index d93bd99..38cc233 100755
--- a/gitk-git/gitk
+++ b/gitk-git/gitk
@@ -2032,6 +2032,7 @@ proc makewindow {} {
     global have_tk85 use_ttk NS
     global git_version
     global worddiff
+    global tagctxmenu
 
     # The "mc" arguments here are purely so that xgettext
     # sees the following string as needing to be translated
@@ -2581,6 +2582,13 @@ proc makewindow {} {
 	{mc "Run git gui blame on this line" command {external_blame_diff}}
     }
     $diff_menu configure -tearoff 0
+
+    set tagctxmenu .tagctxmenu
+    makemenu $tagctxmenu {
+	{mc "Rename this tag" command mvtag}
+	{mc "Delete this tag" command rmtag}
+    }
+    $tagctxmenu configure -tearoff 0
 }
 
 # Windows sends all mouse wheel events to the current focused window, not
@@ -6400,6 +6408,7 @@ proc drawtags {id x xt y1} {
 		   -font $font -tags [list tag.$id text]]
 	if {$ntags >= 0} {
 	    $canv bind $t <1> [list showtag $tag_quoted 1]
+	    $canv bind $t $ctxbut [list showtagmenu %X %Y $id $tag_quoted]
 	} elseif {$nheads >= 0} {
 	    $canv bind $t $ctxbut [list headmenu %X %Y $id $tag_quoted]
 	}
@@ -8931,6 +8940,113 @@ proc domktag {} {
     return 1
 }
 
+proc mvtag {} {
+    global mvtagtop
+    global tagmenuid tagmenutag tagctxmenu maintag NS
+    global mvtagtag
+
+    set mvtagtag $tagmenutag
+    set top .movetag
+    set mvtagtop $top
+    catch {destroy $top}
+    ttk_toplevel $top
+    make_transient $top .
+
+    ${NS}::label $top.msg -text [mc "Enter a new tag name:"]
+    ${NS}::entry $top.tag -width 60 -textvariable mvtagtag
+
+    grid $top.msg -sticky w -row 0 -column 0
+    grid $top.tag -sticky w -row 0 -column 1
+
+    ${NS}::frame $top.buts
+    ${NS}::button $top.buts.gen -text [mc "Rename"] -command mvtaggo
+    ${NS}::button $top.buts.can -text [mc "Cancel"] -command mvtagcan
+    bind $top <Key-Return> mvtaggo
+    bind $top <Key-Escape> mvtagcan
+    grid $top.buts.gen $top.buts.can
+    grid columnconfigure $top.buts 0 -weight 1 -uniform a
+    grid columnconfigure $top.buts 1 -weight 1 -uniform a
+    grid $top.buts - -pady 10 -sticky ew
+}
+
+proc domvtag {} {
+    global mvtagtop env tagids idtags tagmenutag tagmenuid mvtagtag
+
+    set tag $mvtagtag
+    set id $tagmenuid
+
+    # add tag
+    # XXX: reuse domktag including keeping comment from the original tag.
+    if {[catch {
+        exec git tag $tag $id
+    } err]} {
+        error_popup "[mc "Error renaming tag:"] $err" $mvtagtop
+        return 0
+    }
+
+    # delete old tag, content stored in $tagmenutag and $tagmenuid
+    dormtag
+
+    set tagids($tag) $id
+    lappend idtags($id) $tag
+    redrawtags $id
+    addedtag $id
+    dispneartags 0
+    run refill_reflist
+    return 1
+}
+
+proc rmtag {} {
+    global rmtagtop
+    global tagmenuid tagmenutag tagctxmenu maintag NS
+
+    set top .maketag
+    set rmtagtop $top
+    catch {destroy $top}
+    ttk_toplevel $top
+    make_transient $top .
+    ${NS}::label $top.title -text [mc "Delete tag"]
+    grid $top.title - -pady 10
+
+    ${NS}::label $top.msg -text [mc "You are about to delete a tag"]
+    ${NS}::label $top.tagname -foreground Red -text [mc "$tagmenutag"]
+    grid $top.msg -sticky w -row 0 -column 0
+    grid $top.tagname -sticky w -row 0 -column 1
+
+    ${NS}::frame $top.buts
+    ${NS}::button $top.buts.gen -text [mc "Delete"] -command rmtaggo
+    ${NS}::button $top.buts.can -text [mc "Cancel"] -command rmtagcan
+    bind $top <Key-Return> rmtaggo
+    bind $top <Key-Escape> rmtagcan
+    grid $top.buts.gen $top.buts.can
+    grid columnconfigure $top.buts 0 -weight 1 -uniform a
+    grid columnconfigure $top.buts 1 -weight 1 -uniform a
+    grid $top.buts - -pady 10 -sticky ew
+}
+
+proc dormtag {} {
+    global rmtagtop env tagids idtags tagmenutag tagmenuid
+
+    set tag $tagmenutag
+    set id $tagmenuid
+
+    if {[catch {
+        exec git tag -d $tag
+    } err]} {
+        error_popup "[mc "Error deleting tag:"] $err" $rmtagtop
+        return 0
+    }
+
+    unset tagids($tag)
+    set idx [lsearch $idtags($id) $tag]
+    set idtags($id) [lreplace $idtags($id) $idx $idx]
+
+    redrawtags $id
+    dispneartags 0
+    run refill_reflist
+    return 1
+}
+
 proc redrawtags {id} {
     global canv linehtag idpos currentid curview cmitlisted markedid
     global canvxmax iddrawn circleitem mainheadid circlecolors
@@ -8974,6 +9090,30 @@ proc mktaggo {} {
     mktagcan
 }
 
+proc rmtagcan {} {
+    global rmtagtop
+
+    catch {destroy $rmtagtop}
+    unset rmtagtop
+}
+
+proc rmtaggo {} {
+    if {![dormtag]} return
+    rmtagcan
+}
+
+proc mvtagcan {} {
+    global mvtagtop
+
+    catch {destroy $mvtagtop}
+    unset mvtagtop
+}
+
+proc mvtaggo {} {
+    if {![domvtag]} return
+    mvtagcan
+}
+
 proc writecommit {} {
     global rowmenuid wrcomtop commitinfo wrcomcmd NS
 
@@ -9288,6 +9428,20 @@ proc headmenu {x y id head} {
     tk_popup $headctxmenu $x $y
 }
 
+# context menu for a tag
+proc showtagmenu {x y id tag} {
+    global tagmenuid tagmenutag tagctxmenu maintag
+
+    stopfinding
+    set tagmenuid $id
+    set tagmenutag $tag
+    set state normal
+
+    $tagctxmenu entryconfigure 0 -state normal
+    $tagctxmenu entryconfigure 1 -state normal
+    tk_popup $tagctxmenu $x $y
+}
+
 proc cobranch {} {
     global headmenuid headmenuhead headids
     global showlocalchanges
-- 
1.7.9.5

```

## Paul Mackerras, 2013-01-02 07:11

Subject: Re: [PATCH] gitk tag delete/rename support
Message-ID: <20130102071153.GF20724@iris.ozlabs.ibm.com>
URL: https://gitlist.dev/e/20130102071153.GF20724%40iris.ozlabs.ibm.com
In-Reply-To: <1353870345-3054-1-git-send-email-leon.kukovec@gmail.com>

```
On Sun, Nov 25, 2012 at 08:05:45PM +0100, Leon KUKOVEC wrote:

> Right clicking on a tag pops up a menu, which allows
> tag to be renamed or deleted.

Nice idea, but I am concerned that renaming a tag that refers to a tag
object will turn it into a lightweight tag, which would be surprising
for users.  I think that needs to be fixed before I apply the patch.
Also, when renaming a tag it would be good to check for the cases
where the new name is the same as the old (in which case nothing needs
to be done) and where the new name already exists.

Thanks,
Paul.

```
