git-gui: Created Branch menu.
This is an early start at branch management from within git-gui. The branch menu has create/delete command entries to create and delete branches as well as a list of radiobutton entries for each branch found in the repository through for-each-ref. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce committed
Nov 24, 2006 at 17:30 UTC
700a65ce380f29a5083bcc230aa1ef5c28e66f2c
1 file changed
+61
git-gui
+61
@@ -1605,6 +1605,44 @@ proc write_checkout_index {fd pathList totalCnt batch msg after} {
1605
[expr {100.0 * $update_index_cp / $totalCnt}]]
1606
}
1607
1608
+######################################################################
1609
+##
1610
+## branch management
1611
+
1612
+proc load_all_branches {} {
1613
+ global all_branches
1614
+
1615
+ set all_branches [list]
1616
+ set cmd [list git for-each-ref]
1617
+ lappend cmd --format=%(refname)
1618
+ lappend cmd refs/heads
1619
+ set fd [open "| $cmd" r]
1620
+ while {[gets $fd line] > 0} {
1621
+ if {[regsub ^refs/heads/ $line {} line]} {
1622
+ lappend all_branches $line
1623
+ }
1624
+ }
1625
+ close $fd
1626
+
1627
+ set all_branches [lsort $all_branches]
1628
+}
1629
+
1630
+proc populate_branch_menu {m} {
1631
+ global all_branches disable_on_lock
1632
+
1633
+ $m add separator
1634
+ foreach b $all_branches {
1635
+ $m add radiobutton \
1636
+ -label $b \
1637
+ -command [list do_switch_branch $b] \
1638
+ -variable current_branch \
1639
+ -value $b \
1640
+ -font font_ui
1641
+ lappend disable_on_lock \
1642
+ [list $m entryconf [$m index last] -state]
1643
+ }
1644
+}
1645
+
1646
######################################################################
1647
##
1648
## remote management
@@ -2878,6 +2916,9 @@ apply_config
2916
menu .mbar -tearoff 0
2917
.mbar add cascade -label Repository -menu .mbar.repository
2918
.mbar add cascade -label Edit -menu .mbar.edit
2919
+if {!$single_commit} {
2920
+ .mbar add cascade -label Branch -menu .mbar.branch
2921
+}
2922
.mbar add cascade -label Commit -menu .mbar.commit
2923
if {!$single_commit} {
2924
.mbar add cascade -label Fetch -menu .mbar.fetch
@@ -2963,6 +3004,24 @@ menu .mbar.edit
3004
-accelerator $M1T-A \
3005
-font font_ui
3006
3007
+if {!$single_commit} {
3008
+ # -- Branch Menu
3009
+ #
3010
+ menu .mbar.branch
3011
+
3012
+ .mbar.branch add command -label {Create...} \
3013
+ -command do_create_branch \
3014
+ -font font_ui
3015
+ lappend disable_on_lock [list .mbar.branch entryconf \
3016
+ [.mbar.branch index last] -state]
3017
+
3018
+ .mbar.branch add command -label {Delete...} \
3019
+ -command do_delete_branch \
3020
+ -font font_ui
3021
+ lappend disable_on_lock [list .mbar.branch entryconf \
3022
+ [.mbar.branch index last] -state]
3023
+}
3024
+
3025
# -- Commit Menu
3026
#
3027
menu .mbar.commit
@@ -3583,6 +3642,8 @@ user.email settings into your personal
3642
3643
if {!$single_commit} {
3644
load_all_remotes
3645
+ load_all_branches
3646
+ populate_branch_menu .mbar.branch
3647
populate_fetch_menu .mbar.fetch
3648
populate_pull_menu .mbar.pull
3649
populate_push_menu .mbar.push