@matheusbsbs / matheus-bagliano / commits / 8553b772d7
Fork 0

git-gui: Display the current branch.

Users want to know what branch they are sitting on before making a commit, as they may need to switch to a different branch first. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed Nov 24, 2006 at 15:38 UTC 8553b772d7aeebe8c83710233877483dd409b846
1 file changed +30 -1
git-gui
+30 -1
@@ -258,11 +258,20 @@ proc unlock_index {} {
258 ## status
259
260 proc repository_state {ctvar hdvar mhvar} {
261 - global gitdir
261 + global gitdir current_branch
262 upvar $ctvar ct $hdvar hd $mhvar mh
263
264 set mh [list]
265
266 + if {[catch {set current_branch [exec git symbolic-ref HEAD]}]} {
267 + set current_branch {}
268 + } else {
269 + regsub ^refs/(heads|tags)/ \
270 + $current_branch \
271 + {} \
272 + current_branch
273 + }
274 +
275 if {[catch {set hd [exec git rev-parse --verify HEAD]}]} {
276 set hd {}
277 set ct initial
@@ -3060,6 +3069,25 @@ if {[is_MacOSX]} {
3069 }
3070
3071
3072 +# -- Branch Control
3073 +#
3074 +frame .branch \
3075 + -borderwidth 1 \
3076 + -relief sunken
3077 +label .branch.l1 \
3078 + -text {Current Branch:} \
3079 + -anchor w \
3080 + -justify left \
3081 + -font font_ui
3082 +label .branch.cb \
3083 + -textvariable current_branch \
3084 + -anchor w \
3085 + -justify left \
3086 + -font font_ui
3087 +pack .branch.l1 -side left
3088 +pack .branch.cb -side left -fill x
3089 +pack .branch -side top -fill x
3090 +
3091 # -- Main Window Layout
3092 #
3093 panedwindow .vpane -orient vertical
@@ -3486,6 +3514,7 @@ set PARENT {}
3514 set MERGE_HEAD [list]
3515 set commit_type {}
3516 set empty_tree {}
3517 +set current_branch {}
3518 set current_diff {}
3519 set selected_commit_type new
3520