summaryrefslogtreecommitdiff
path: root/git-gui
diff options
context:
space:
mode:
authorShawn O. Pearce <spearce@spearce.org>2006-11-16 03:13:45 (GMT)
committerShawn O. Pearce <spearce@spearce.org>2006-11-18 04:56:15 (GMT)
commitfbee8500a5b64a1c0c6103232879bcecc30f64b4 (patch)
treea22794046c1244c0e73be95d0125c6cdbe1386b8 /git-gui
parentb3678bacbcd2dc0e1c61fd91f4146d0c037e626f (diff)
downloadgit-fbee8500a5b64a1c0c6103232879bcecc30f64b4.zip
git-fbee8500a5b64a1c0c6103232879bcecc30f64b4.tar.gz
git-fbee8500a5b64a1c0c6103232879bcecc30f64b4.tar.bz2
git-gui: Correctly handle GIT_DIR environment variable.
Some users may want to start us by running "git --git-dir=... gui" rather than trying to cd into the directory first. This is especially true if they want to just make a shortcut to our executable on Windows and always have that associated with a certain repository. Since Tcl on Windows throws away our environment and doesn't pass it down to the child process correctly we cannot call git-rev-parse to get the GIT_DIR environment variable. So instead we ask for it specifically ourselves; if its not defined then we ask rev-parse. This should actually reduce startup by 1 fork/exec if we were started as "git gui" as GIT_DIR will be set for us. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'git-gui')
-rwxr-xr-xgit-gui11
1 files changed, 6 insertions, 5 deletions
diff --git a/git-gui b/git-gui
index 8449664..7c2f803 100755
--- a/git-gui
+++ b/git-gui
@@ -161,16 +161,17 @@ proc info_popup {msg} {
##
## repository setup
-if { [catch {set cdup [exec git rev-parse --show-cdup]} err]
- || [catch {set gitdir [exec git rev-parse --git-dir]} err]} {
+if { [catch {set gitdir $env(GIT_DIR)}]
+ && [catch {set gitdir [exec git rev-parse --git-dir]} err]} {
catch {wm withdraw .}
error_popup "Cannot find the git directory:\n\n$err"
exit 1
}
-if {$cdup ne ""} {
- cd $cdup
+if {[catch {cd [file dirname $gitdir]} err]} {
+ catch {wm withdraw .}
+ error_popup "No working directory [file dirname $gitdir]:\n\n$err"
+ exit 1
}
-unset cdup
set single_commit 0
if {$appname eq {git-citool}} {