@matheusbsbs / matheus-bagliano / commits / 101e3ae7a6
Fork 0

git-gui: Create new branches from a tag.

I'm missing the possibility to base a new branch on a tag. The following adds a tag drop down to the new branch dialog. Signed-off-by: Martin Koegler <mkoegler@auto.tuwien.ac.at> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Martin Koegler committed Feb 15, 2007 at 01:28 UTC 101e3ae7a6b041aa86505bfd3e8b901f1dc245c3
1 file changed +30
git-gui.sh
+30
@@ -1916,11 +1916,24 @@ proc all_tracking_branches {} {
1916 return [lsort -unique $all_trackings]
1917 }
1918
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 +
1931 proc do_create_branch_action {w} {
1932 global all_heads null_sha1 repo_config
1933 global create_branch_checkout create_branch_revtype
1934 global create_branch_head create_branch_trackinghead
1935 global create_branch_name create_branch_revexp
1936 + global create_branch_tag
1937
1938 set newbranch $create_branch_name
1939 if {$newbranch eq {}
@@ -1959,6 +1972,7 @@ proc do_create_branch_action {w} {
1972 switch -- $create_branch_revtype {
1973 head {set rev $create_branch_head}
1974 tracking {set rev $create_branch_trackinghead}
1975 + tag {set rev $create_branch_tag}
1976 expression {set rev $create_branch_revexp}
1977 }
1978 if {[catch {set cmt [git rev-parse --verify "${rev}^0"]}]} {
@@ -2004,6 +2018,8 @@ trace add variable create_branch_head write \
2018 [list radio_selector create_branch_revtype head]
2019 trace add variable create_branch_trackinghead write \
2020 [list radio_selector create_branch_revtype tracking]
2021 +trace add variable create_branch_tag write \
2022 + [list radio_selector create_branch_revtype tag]
2023
2024 trace add variable delete_branch_head write \
2025 [list radio_selector delete_branch_checktype head]
@@ -2015,6 +2031,7 @@ proc do_create_branch {} {
2031 global create_branch_checkout create_branch_revtype
2032 global create_branch_head create_branch_trackinghead
2033 global create_branch_name create_branch_revexp
2034 + global create_branch_tag
2035
2036 set w .branch_editor
2037 toplevel $w
@@ -2078,6 +2095,19 @@ proc do_create_branch {} {
2095 $all_trackings
2096 grid $w.from.tracking_r $w.from.tracking_m -sticky w
2097 }
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 + }
2111 radiobutton $w.from.exp_r \
2112 -text {Revision Expression:} \
2113 -value expression \