]> asedeno.scripts.mit.edu Git - git.git/blobdiff - git-gui.sh
git-gui: Allow users to delete remote branches
[git.git] / git-gui.sh
index d238d452385e73ab4b43c0d38284a35388ba8f03..c5f132993295d7f915255071b4005e44003d8c3a 100755 (executable)
@@ -20,6 +20,24 @@ You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA}
 
+######################################################################
+##
+## enable verbose loading?
+
+if {![catch {set _verbose $env(GITGUI_VERBOSE)}]} {
+       unset _verbose
+       rename auto_load real__auto_load
+       proc auto_load {name args} {
+               puts stderr "auto_load $name"
+               return [uplevel 1 real__auto_load $name $args]
+       }
+       rename source real__source
+       proc source {name} {
+               puts stderr "source    $name"
+               uplevel 1 real__source $name
+       }
+}
+
 ######################################################################
 ##
 ## configure our library
@@ -32,26 +50,33 @@ if {$oguirel eq {1}} {
 } elseif {[string match @@* $oguirel]} {
        set oguilib [file join [file dirname [file normalize $argv0]] lib]
 }
+
 set idx [file join $oguilib tclIndex]
-catch {
-       set fd [open $idx r]
-       if {[gets $fd] eq {# Autogenerated by git-gui Makefile}} {
-               set idx [list]
-               while {[gets $fd n] >= 0} {
-                       if {$n ne {} && ![string match #* $n]} {
-                               lappend idx $n
-                       }
+if {[catch {set fd [open $idx r]} err]} {
+       catch {wm withdraw .}
+       tk_messageBox \
+               -icon error \
+               -type ok \
+               -title "git-gui: fatal error" \
+               -message $err
+       exit 1
+}
+if {[gets $fd] eq {# Autogenerated by git-gui Makefile}} {
+       set idx [list]
+       while {[gets $fd n] >= 0} {
+               if {$n ne {} && ![string match #* $n]} {
+                       lappend idx $n
                }
-       } else {
-               set idx {}
        }
-       close $fd
+} else {
+       set idx {}
 }
+close $fd
+
 if {$idx ne {}} {
        set loaded [list]
        foreach p $idx {
                if {[lsearch -exact $loaded $p] >= 0} continue
-               puts $p
                source [file join $oguilib $p]
                lappend loaded $p
        }
@@ -59,21 +84,7 @@ if {$idx ne {}} {
 } else {
        set auto_path [concat [list $oguilib] $auto_path]
 }
-unset -nocomplain oguilib oguirel idx fd
-
-if {![catch {set _verbose $env(GITGUI_VERBOSE)}]} {
-       unset _verbose
-       rename auto_load real__auto_load
-       proc auto_load {name args} {
-               puts stderr "auto_load $name"
-               return [uplevel 1 real__auto_load $name $args]
-       }
-       rename source real__source
-       proc source {name} {
-               puts stderr "source    $name"
-               uplevel 1 real__source $name
-       }
-}
+unset -nocomplain oguirel idx fd
 
 ######################################################################
 ##
@@ -189,6 +200,15 @@ proc is_config_true {name} {
        }
 }
 
+proc get_config {name} {
+       global repo_config
+       if {[catch {set v $repo_config($name)}]} {
+               return {}
+       } else {
+               return $v
+       }
+}
+
 proc load_config {include_global} {
        global repo_config global_config default_config
 
@@ -1210,6 +1230,10 @@ foreach class {Button Checkbutton Entry Label
 }
 unset class
 
+if {[is_Windows] || [is_MacOSX]} {
+       option add *Menu.tearOff 0
+}
+
 if {[is_MacOSX]} {
        set M1B M1
        set M1T Cmd
@@ -1405,6 +1429,11 @@ if {[is_enabled branch]} {
        lappend disable_on_lock [list .mbar.branch entryconf \
                [.mbar.branch index last] -state]
 
+       .mbar.branch add command -label {Rename...} \
+               -command branch_rename::dialog
+       lappend disable_on_lock [list .mbar.branch entryconf \
+               [.mbar.branch index last] -state]
+
        .mbar.branch add command -label {Delete...} \
                -command do_delete_branch
        lappend disable_on_lock [list .mbar.branch entryconf \
@@ -1502,6 +1531,8 @@ if {[is_enabled transport]} {
        menu .mbar.push
        .mbar.push add command -label {Push...} \
                -command do_push_anywhere
+       .mbar.push add command -label {Delete...} \
+               -command remote_branch_delete::dialog
 }
 
 if {[is_MacOSX]} {