git-gui: Allow creating branches from tracking heads.
Sometimes you want to create a branch from a remote tracking branch. Needing to enter it in the revision expression field is very annoying, so instead let the user select it from a list of known tracking branches. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce committed
Jan 21, 2007 at 02:27 UTC
859d8057bd0194bf21fac74d196cd9c07e2fec19
1 file changed
+29
-3
git-gui.sh
+29
-3
@@ -1656,7 +1656,8 @@ proc populate_branch_menu {} {
1656
1657
proc do_create_branch_action {w} {
1658
global all_heads null_sha1
1659
- global create_branch_checkout create_branch_revtype create_branch_head
1659
+ global create_branch_checkout create_branch_revtype
1660
+ global create_branch_head create_branch_trackinghead
1661
1662
set newbranch [string trim [$w.name.t get 0.0 end]]
1663
if {![catch {exec git show-ref --verify -- "refs/heads/$newbranch"}]} {
@@ -1683,6 +1684,7 @@ proc do_create_branch_action {w} {
1684
set rev {}
1685
switch -- $create_branch_revtype {
1686
head {set rev $create_branch_head}
1687
+ tracking {set rev $create_branch_trackinghead}
1688
expression {set rev [string trim [$w.from.exp.t get 0.0 end]]}
1689
}
1690
if {[catch {set cmt [exec git rev-parse --verify "${rev}^0"]}]} {
@@ -1717,12 +1719,14 @@ proc do_create_branch_action {w} {
1719
}
1720
1721
proc do_create_branch {} {
1720
- global all_heads current_branch
1721
- global create_branch_checkout create_branch_revtype create_branch_head
1722
+ global all_heads current_branch tracking_branches
1723
+ global create_branch_checkout create_branch_revtype
1724
+ global create_branch_head create_branch_trackinghead
1725
1726
set create_branch_checkout true
1727
set create_branch_revtype head
1728
set create_branch_head $current_branch
1729
+ set create_branch_trackinghead {}
1730
1731
set w .branch_editor
1732
toplevel $w
@@ -1768,6 +1772,16 @@ proc do_create_branch {} {
1772
pack $w.name.t -side left -fill x -expand 1
1773
pack $w.name -anchor nw -fill x -pady 5 -padx 5
1774
1775
+ set all_trackings [list]
1776
+ foreach b [array names tracking_branches] {
1777
+ regsub ^refs/(heads|remotes)/ $b {} b
1778
+ lappend all_trackings $b
1779
+ }
1780
+ set all_trackings [lsort -unique $all_trackings]
1781
+ if {$all_trackings ne {}} {
1782
+ set create_branch_trackinghead [lindex $all_trackings 0]
1783
+ }
1784
+
1785
labelframe $w.from \
1786
-text {Starting Revision} \
1787
-font font_ui
@@ -1780,6 +1794,17 @@ proc do_create_branch {} {
1794
eval tk_optionMenu $w.from.head.m create_branch_head $all_heads
1795
pack $w.from.head.r -side left
1796
pack $w.from.head.m -side left
1797
+ frame $w.from.tracking
1798
+ radiobutton $w.from.tracking.r \
1799
+ -text {Tracking Branch:} \
1800
+ -value tracking \
1801
+ -variable create_branch_revtype \
1802
+ -font font_ui
1803
+ eval tk_optionMenu $w.from.tracking.m \
1804
+ create_branch_trackinghead \
1805
+ $all_trackings
1806
+ pack $w.from.tracking.r -side left
1807
+ pack $w.from.tracking.m -side left
1808
frame $w.from.exp
1809
radiobutton $w.from.exp.r \
1810
-text {Revision Expression:} \
@@ -1796,6 +1821,7 @@ proc do_create_branch {} {
1821
pack $w.from.exp.r -side left
1822
pack $w.from.exp.t -side left -fill x -expand 1
1823
pack $w.from.head -padx 5 -fill x -expand 1
1824
+ pack $w.from.tracking -padx 5 -fill x -expand 1
1825
pack $w.from.exp -padx 5 -fill x -expand 1
1826
pack $w.from -anchor nw -fill x -pady 5 -padx 5
1827