git-gui: Protect ourselves from funny GIT_DIR/working directory setups.
Since we have some serious problems with the GIT_DIR environment variable on Windows we cannot let the user use a non-standard GIT_DIR with their working directory. So require that the GIT_DIR name is actually ".git", that it exists, and that its parent directory is our working directory. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Shawn O. Pearce committed
Nov 15, 2006 at 22:45 UTC
dbccbbda4f4c049552495a87b1747b1b2a1e2823
1 file changed
+12
-2
git-gui
+12
-2
@@ -167,6 +167,16 @@ if { [catch {set gitdir $env(GIT_DIR)}]
167
error_popup "Cannot find the git directory:\n\n$err"
168
exit 1
169
}
170
+if {![file isdirectory $gitdir]} {
171
+ catch {wm withdraw .}
172
+ error_popup "Git directory not found:\n\n$gitdir"
173
+ exit 1
174
+}
175
+if {[lindex [file split $gitdir] end] ne {.git}} {
176
+ catch {wm withdraw .}
177
+ error_popup "Cannot use funny .git directory:\n\n$gitdir"
178
+ exit 1
179
+}
180
if {[catch {cd [file dirname $gitdir]} err]} {
181
catch {wm withdraw .}
182
error_popup "No working directory [file dirname $gitdir]:\n\n$err"
@@ -2040,8 +2050,8 @@ proc do_windows_shortcut {} {
2050
--absolute \
2051
$gitdir]
2052
puts -nonewline $fd "\"$sh\" --login -c \""
2043
- puts -nonewline $fd "GIT_DIR=\\\"$gd\\\""
2044
- puts -nonewline $fd " \\\"$me\\\""
2053
+ puts -nonewline $fd "GIT_DIR='$gd'"
2054
+ puts -nonewline $fd " '$me'"
2055
puts $fd "&\""
2056
close $fd
2057
} err]} {