summaryrefslogtreecommitdiff
path: root/git-gui/git-gui.sh
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2007-06-11 07:52:43 (GMT)
committerJunio C Hamano <gitster@pobox.com>2007-06-11 07:52:43 (GMT)
commit75d8ff138dd640a117c6aaa625d0f6b835adbd3a (patch)
tree3fe3467ed5b90dfef595a324a7134cb2b6f192ef /git-gui/git-gui.sh
parent27c1dbea3e3a23b3c4b3707dfc9a71c3279ae279 (diff)
parent32af629ab57869f96f282e7f7839e84d1b8e22ca (diff)
downloadgit-75d8ff138dd640a117c6aaa625d0f6b835adbd3a.zip
git-75d8ff138dd640a117c6aaa625d0f6b835adbd3a.tar.gz
git-75d8ff138dd640a117c6aaa625d0f6b835adbd3a.tar.bz2
Merge branch 'master' of git://repo.or.cz/git-gui
* 'master' of git://repo.or.cz/git-gui: git-gui: Internalize symbolic-ref HEAD reading logic git-gui: Expose the merge.diffstat configuration option git-gui: Allow users to delete remote branches git-gui: Allow users to rename branches through 'branch -m' git-gui: Disable tearoff menus on Windows, Mac OS X git-gui: Provide fatal error if library is unavailable git-gui: Enable verbose Tcl loading earlier git-gui: Show the git-gui library path in 'About git-gui' git-gui: GUI support for running 'git remote prune <name>' git gui 0.8.0
Diffstat (limited to 'git-gui/git-gui.sh')
-rwxr-xr-xgit-gui/git-gui.sh122
1 files changed, 75 insertions, 47 deletions
diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh
index dfb4b95..e33ee03 100755
--- a/git-gui/git-gui.sh
+++ b/git-gui/git-gui.sh
@@ -38,6 +38,24 @@ if {[catch {package require Tcl 8.4} err]
######################################################################
##
+## 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
set oguilib {@@GITGUI_LIBDIR@@}
@@ -48,26 +66,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
}
@@ -75,21 +100,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
######################################################################
##
@@ -205,6 +216,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
@@ -258,6 +278,17 @@ proc git {args} {
return [eval exec git $args]
}
+proc current-branch {} {
+ set ref {}
+ set fd [open [gitdir HEAD] r]
+ if {[gets $fd ref] <16
+ || ![regsub {^ref: refs/heads/} $ref {} ref]} {
+ set ref {}
+ }
+ close $fd
+ return $ref
+}
+
auto_load tk_optionMenu
rename tk_optionMenu real__tkOptionMenu
proc tk_optionMenu {w varName args} {
@@ -406,15 +437,7 @@ proc repository_state {ctvar hdvar mhvar} {
set mh [list]
- if {[catch {set current_branch [git symbolic-ref HEAD]}]} {
- set current_branch {}
- } else {
- regsub ^refs/((heads|tags|remotes)/)? \
- $current_branch \
- {} \
- current_branch
- }
-
+ set current_branch [current-branch]
if {[catch {set hd [git rev-parse --verify HEAD]}]} {
set hd {}
set ct initial
@@ -1229,6 +1252,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
@@ -1259,11 +1286,13 @@ proc apply_config {} {
}
}
+set default_config(merge.diffstat) true
set default_config(merge.summary) false
set default_config(merge.verbosity) 2
set default_config(user.name) {}
set default_config(user.email) {}
+set default_config(gui.pruneduringfetch) false
set default_config(gui.trustmtime) false
set default_config(gui.diffcontext) 5
set default_config(gui.newbranchtemplate) {}
@@ -1425,6 +1454,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 \
@@ -1522,6 +1556,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]} {
@@ -1639,14 +1675,8 @@ switch -- $subcommand {
browser {
set subcommand_args {rev?}
switch [llength $argv] {
- 0 {
- set current_branch [git symbolic-ref HEAD]
- regsub ^refs/((heads|tags|remotes)/)? \
- $current_branch {} current_branch
- }
- 1 {
- set current_branch [lindex $argv 0]
- }
+ 0 { set current_branch [current-branch] }
+ 1 { set current_branch [lindex $argv 0] }
default usage
}
browser::new $current_branch
@@ -1679,9 +1709,7 @@ blame {
unset is_path
if {$head eq {}} {
- set current_branch [git symbolic-ref HEAD]
- regsub ^refs/((heads|tags|remotes)/)? \
- $current_branch {} current_branch
+ set current_branch [current-branch]
} else {
set current_branch $head
}