Code

git-gui: Don't offer tracking branches if none exist.
[git.git] / git-gui.sh
index d26868beca6a290bfe033d4b2318769d03e3d328..c4ab824b9d860d06e0fe9239671cf2653cc4e396 100755 (executable)
@@ -708,7 +708,8 @@ proc read_diff {fd} {
                #
                if {[string match {@@@ *} $line]} {set is_3way_diff 1}
 
-               if {[string match {index *} $line]} {
+               if {[string match {index *} $line]
+                       || [regexp {^\* Unmerged path } $line]} {
                        set tags {}
                } elseif {$is_3way_diff} {
                        set op [string range $line 0 1]
@@ -1678,6 +1679,17 @@ proc populate_branch_menu {} {
        }
 }
 
+proc all_tracking_branches {} {
+       global tracking_branches
+
+       set all_trackings [list]
+       foreach b [array names tracking_branches] {
+               regsub ^refs/(heads|remotes)/ $b {} b
+               lappend all_trackings $b
+       }
+       return [lsort -unique $all_trackings]
+}
+
 proc do_create_branch_action {w} {
        global all_heads null_sha1
        global create_branch_checkout create_branch_revtype
@@ -1746,7 +1758,7 @@ proc do_create_branch_action {w} {
 }
 
 proc do_create_branch {} {
-       global all_heads current_branch tracking_branches
+       global all_heads current_branch
        global create_branch_checkout create_branch_revtype
        global create_branch_head create_branch_trackinghead
 
@@ -1801,16 +1813,6 @@ proc do_create_branch {} {
        grid columnconfigure $w.desc 1 -weight 1
        pack $w.desc -anchor nw -fill x -pady 5 -padx 5
 
-       set all_trackings [list]
-       foreach b [array names tracking_branches] {
-               regsub ^refs/(heads|remotes)/ $b {} b
-               lappend all_trackings $b
-       }
-       set all_trackings [lsort -unique $all_trackings]
-       if {$all_trackings ne {}} {
-               set create_branch_trackinghead [lindex $all_trackings 0]
-       }
-
        labelframe $w.from \
                -text {Starting Revision} \
                -font font_ui
@@ -1821,15 +1823,19 @@ proc do_create_branch {} {
                -font font_ui
        eval tk_optionMenu $w.from.head_m create_branch_head $all_heads
        grid $w.from.head_r $w.from.head_m -sticky w
-       radiobutton $w.from.tracking_r \
-               -text {Tracking Branch:} \
-               -value tracking \
-               -variable create_branch_revtype \
-               -font font_ui
-       eval tk_optionMenu $w.from.tracking_m \
-               create_branch_trackinghead \
-               $all_trackings
-       grid $w.from.tracking_r $w.from.tracking_m -sticky w
+       set all_trackings [all_tracking_branches]
+       if {$all_trackings ne {}} {
+               set create_branch_trackinghead [lindex $all_trackings 0]
+               radiobutton $w.from.tracking_r \
+                       -text {Tracking Branch:} \
+                       -value tracking \
+                       -variable create_branch_revtype \
+                       -font font_ui
+               eval tk_optionMenu $w.from.tracking_m \
+                       create_branch_trackinghead \
+                       $all_trackings
+               grid $w.from.tracking_r $w.from.tracking_m -sticky w
+       }
        radiobutton $w.from.exp_r \
                -text {Revision Expression:} \
                -value expression \
@@ -1999,16 +2005,6 @@ proc do_delete_branch {} {
        pack $w.list.l -fill both -pady 5 -padx 5
        pack $w.list -fill both -pady 5 -padx 5
 
-       set all_trackings [list]
-       foreach b [array names tracking_branches] {
-               regsub ^refs/(heads|remotes)/ $b {} b
-               lappend all_trackings $b
-       }
-       set all_trackings [lsort -unique $all_trackings]
-       if {$all_trackings ne {} && $delete_branch_trackinghead eq {}} {
-               set delete_branch_trackinghead [lindex $all_trackings 0]
-       }
-
        labelframe $w.validate \
                -text {Delete Only If} \
                -font font_ui
@@ -2019,15 +2015,19 @@ proc do_delete_branch {} {
                -font font_ui
        eval tk_optionMenu $w.validate.head_m delete_branch_head $all_heads
        grid $w.validate.head_r $w.validate.head_m -sticky w
-       radiobutton $w.validate.tracking_r \
-               -text {Merged Into Tracking Branch:} \
-               -value tracking \
-               -variable delete_branch_checktype \
-               -font font_ui
-       eval tk_optionMenu $w.validate.tracking_m \
-               delete_branch_trackinghead \
-               $all_trackings
-       grid $w.validate.tracking_r $w.validate.tracking_m -sticky w
+       set all_trackings [all_tracking_branches]
+       if {$all_trackings ne {}} {
+               set delete_branch_trackinghead [lindex $all_trackings 0]
+               radiobutton $w.validate.tracking_r \
+                       -text {Merged Into Tracking Branch:} \
+                       -value tracking \
+                       -variable delete_branch_checktype \
+                       -font font_ui
+               eval tk_optionMenu $w.validate.tracking_m \
+                       delete_branch_trackinghead \
+                       $all_trackings
+               grid $w.validate.tracking_r $w.validate.tracking_m -sticky w
+       }
        radiobutton $w.validate.always_r \
                -text {Always (Do not perform merge checks)} \
                -value always \
@@ -3653,13 +3653,17 @@ label .vpane.files.index.title -text {Changes To Be Committed} \
        -font font_ui
 text $ui_index -background white -borderwidth 0 \
        -width 40 -height 10 \
+       -wrap none \
        -font font_ui \
        -cursor $cursor_ptr \
-       -yscrollcommand {.vpane.files.index.sb set} \
+       -xscrollcommand {.vpane.files.index.sx set} \
+       -yscrollcommand {.vpane.files.index.sy set} \
        -state disabled
-scrollbar .vpane.files.index.sb -command [list $ui_index yview]
+scrollbar .vpane.files.index.sx -orient h -command [list $ui_index xview]
+scrollbar .vpane.files.index.sy -orient v -command [list $ui_index yview]
 pack .vpane.files.index.title -side top -fill x
-pack .vpane.files.index.sb -side right -fill y
+pack .vpane.files.index.sx -side bottom -fill x
+pack .vpane.files.index.sy -side right -fill y
 pack $ui_index -side left -fill both -expand 1
 .vpane.files add .vpane.files.index -sticky nsew
 
@@ -3671,13 +3675,17 @@ label .vpane.files.workdir.title -text {Changed But Not Updated} \
        -font font_ui
 text $ui_workdir -background white -borderwidth 0 \
        -width 40 -height 10 \
+       -wrap none \
        -font font_ui \
        -cursor $cursor_ptr \
-       -yscrollcommand {.vpane.files.workdir.sb set} \
+       -xscrollcommand {.vpane.files.workdir.sx set} \
+       -yscrollcommand {.vpane.files.workdir.sy set} \
        -state disabled
-scrollbar .vpane.files.workdir.sb -command [list $ui_workdir yview]
+scrollbar .vpane.files.workdir.sx -orient h -command [list $ui_workdir xview]
+scrollbar .vpane.files.workdir.sy -orient v -command [list $ui_workdir yview]
 pack .vpane.files.workdir.title -side top -fill x
-pack .vpane.files.workdir.sb -side right -fill y
+pack .vpane.files.workdir.sx -side bottom -fill x
+pack .vpane.files.workdir.sy -side right -fill y
 pack $ui_workdir -side left -fill both -expand 1
 .vpane.files add .vpane.files.workdir -sticky nsew
 
@@ -3915,24 +3923,24 @@ pack $ui_diff -side left -fill both -expand 1
 pack .vpane.lower.diff.header -side top -fill x
 pack .vpane.lower.diff.body -side bottom -fill both -expand 1
 
-$ui_diff tag conf d_@ -font font_diffbold
-$ui_diff tag conf d_+ -foreground blue
+$ui_diff tag conf d_@ -foreground blue -font font_diffbold
+$ui_diff tag conf d_+ -foreground {#00a000}
 $ui_diff tag conf d_- -foreground red
 
-$ui_diff tag conf d_++ -foreground blue
+$ui_diff tag conf d_++ -foreground {#00a000}
 $ui_diff tag conf d_-- -foreground red
 $ui_diff tag conf d_+s \
-       -foreground blue \
-       -background azure2
+       -foreground {#00a000} \
+       -background {#e2effa}
 $ui_diff tag conf d_-s \
        -foreground red \
-       -background azure2
+       -background {#e2effa}
 $ui_diff tag conf d_s+ \
-       -foreground blue \
-       -background {light goldenrod yellow}
+       -foreground {#00a000} \
+       -background ivory1
 $ui_diff tag conf d_s- \
        -foreground red \
-       -background {light goldenrod yellow}
+       -background ivory1
 
 $ui_diff tag conf d<<<<<<< \
        -foreground orange \
@@ -3944,6 +3952,8 @@ $ui_diff tag conf d>>>>>>> \
        -foreground orange \
        -font font_diffbold
 
+$ui_diff tag raise sel
+
 # -- Diff Body Context Menu
 #
 set ctxm .vpane.lower.diff.body.ctxm