@@ -1916,11 +1916,24 @@ proc all_tracking_branches {} {
19161916 return [lsort -unique $all_trackings ]
19171917}
19181918
1919+ proc load_all_tags {} {
1920+ set all_tags [list ]
1921+ set fd [open " | git for-each-ref --format=%(refname) refs/tags" r]
1922+ while {[gets $fd line] > 0} {
1923+ if {![regsub ^refs/tags/ $line {} name]} continue
1924+ lappend all_tags $name
1925+ }
1926+ close $fd
1927+
1928+ return [lsort $all_tags ]
1929+ }
1930+
19191931proc do_create_branch_action {w} {
19201932 global all_heads null_sha1 repo_config
19211933 global create_branch_checkout create_branch_revtype
19221934 global create_branch_head create_branch_trackinghead
19231935 global create_branch_name create_branch_revexp
1936+ global create_branch_tag
19241937
19251938 set newbranch $create_branch_name
19261939 if {$newbranch eq {}
@@ -1959,6 +1972,7 @@ proc do_create_branch_action {w} {
19591972 switch -- $create_branch_revtype {
19601973 head {set rev $create_branch_head }
19611974 tracking {set rev $create_branch_trackinghead }
1975+ tag {set rev $create_branch_tag }
19621976 expression {set rev $create_branch_revexp }
19631977 }
19641978 if {[catch {set cmt [git rev-parse --verify " ${rev} ^0" ]}]} {
@@ -2004,6 +2018,8 @@ trace add variable create_branch_head write \
20042018 [list radio_selector create_branch_revtype head]
20052019trace add variable create_branch_trackinghead write \
20062020 [list radio_selector create_branch_revtype tracking]
2021+ trace add variable create_branch_tag write \
2022+ [list radio_selector create_branch_revtype tag]
20072023
20082024trace add variable delete_branch_head write \
20092025 [list radio_selector delete_branch_checktype head]
@@ -2015,6 +2031,7 @@ proc do_create_branch {} {
20152031 global create_branch_checkout create_branch_revtype
20162032 global create_branch_head create_branch_trackinghead
20172033 global create_branch_name create_branch_revexp
2034+ global create_branch_tag
20182035
20192036 set w .branch_editor
20202037 toplevel $w
@@ -2078,6 +2095,19 @@ proc do_create_branch {} {
20782095 $all_trackings
20792096 grid $w .from.tracking_r $w .from.tracking_m -sticky w
20802097 }
2098+ set all_tags [load_all_tags]
2099+ if {$all_tags ne {}} {
2100+ set create_branch_tag [lindex $all_tags 0]
2101+ radiobutton $w .from.tag_r \
2102+ -text {Tag:} \
2103+ -value tag \
2104+ -variable create_branch_revtype \
2105+ -font font_ui
2106+ eval tk_optionMenu $w .from.tag_m \
2107+ create_branch_tag \
2108+ $all_tags
2109+ grid $w .from.tag_r $w .from.tag_m -sticky w
2110+ }
20812111 radiobutton $w .from.exp_r \
20822112 -text {Revision Expression:} \
20832113 -value expression \
0 commit comments