@matheusbsbs / matheus-bagliano / commits / fbee8500a5
Fork 0

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>

Shawn O. Pearce committed Nov 15, 2006 at 22:13 UTC fbee8500a5b64a1c0c6103232879bcecc30f64b4
1 file changed +6 -5
git-gui
+6 -5
@@ -161,16 +161,17 @@ proc info_popup {msg} {
161 ##
162 ## repository setup
163
164 -if { [catch {set cdup [exec git rev-parse --show-cdup]} err]
165 - || [catch {set gitdir [exec git rev-parse --git-dir]} err]} {
164 +if { [catch {set gitdir $env(GIT_DIR)}]
165 + && [catch {set gitdir [exec git rev-parse --git-dir]} err]} {
166 catch {wm withdraw .}
167 error_popup "Cannot find the git directory:\n\n$err"
168 exit 1
169 }
170 -if {$cdup ne ""} {
171 - cd $cdup
170 +if {[catch {cd [file dirname $gitdir]} err]} {
171 + catch {wm withdraw .}
172 + error_popup "No working directory [file dirname $gitdir]:\n\n$err"
173 + exit 1
174 }
173 -unset cdup
175
176 set single_commit 0
177 if {$appname eq {git-citool}} {