@matheusbsbs / matheus-bagliano / commits / 1d8b3cbf28
Fork 0

git-gui: Warn Cygwin users about possible environment issues.

Because the Tcl binary distributed with Cygwin tends to not pass along its own environment (the env array) to its children, its unlikely that any Git commands spawned by git-gui will receive the same environment variables that git-gui itself received from the shell which started it. If the user is counting on environment variables to pass down, like say GIT_INDEX_FILE, they may not, so we warn them during git-gui startup that things may not work out as the user intended. Perhaps one day when git-gui and git are running on native Windows (rather than through the Cygwin emulation layers) things will work better. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Shawn O. Pearce committed Nov 21, 2006 at 15:28 UTC 1d8b3cbf2841612791178853efbfe9ba60b48f2b
1 file changed +81 -1
git-gui
+81 -1
@@ -145,6 +145,28 @@ proc error_popup {msg} {
145 eval $cmd
146 }
147
148 +proc warn_popup {msg} {
149 + global gitdir appname
150 +
151 + set title $appname
152 + if {$gitdir ne {}} {
153 + append title { (}
154 + append title [lindex \
155 + [file split [file normalize [file dirname $gitdir]]] \
156 + end]
157 + append title {)}
158 + }
159 + set cmd [list tk_messageBox \
160 + -icon warning \
161 + -type ok \
162 + -title "$title: warning" \
163 + -message $msg]
164 + if {[winfo ismapped .]} {
165 + lappend cmd -parent .
166 + }
167 + eval $cmd
168 +}
169 +
170 proc info_popup {msg} {
171 global gitdir appname
172
@@ -158,7 +180,7 @@ proc info_popup {msg} {
180 }
181 tk_messageBox \
182 -parent . \
161 - -icon error \
183 + -icon info \
184 -type ok \
185 -title $title \
186 -message $msg
@@ -3279,6 +3301,64 @@ set selected_commit_type new
3301
3302 wm title . "$appname ([file normalize [file dirname $gitdir]])"
3303 focus -force $ui_comm
3304 +
3305 +# -- Warn the user about environmental problems.
3306 +# Cygwin's Tcl does *not* pass its env array
3307 +# onto any processes it spawns. This means
3308 +# that the git processes get none of our
3309 +# environment. That may not work...
3310 +#
3311 +if {[is_Windows]} {
3312 + set ignored_env 0
3313 + set suggest_user {}
3314 + set msg "Possible environment issues exist.
3315 +
3316 +The following environment variables are probably
3317 +going to be ignored by any Git subprocess run
3318 +by $appname:
3319 +
3320 +"
3321 + foreach name [array names env] {
3322 + switch -regexp -- $name {
3323 + {^GIT_INDEX_FILE$} -
3324 + {^GIT_OBJECT_DIRECTORY$} -
3325 + {^GIT_ALTERNATE_OBJECT_DIRECTORIES$} -
3326 + {^GIT_DIFF_OPTS$} -
3327 + {^GIT_EXTERNAL_DIFF$} -
3328 + {^GIT_PAGER$} -
3329 + {^GIT_TRACE$} -
3330 + {^GIT_CONFIG$} -
3331 + {^GIT_CONFIG_LOCAL$} -
3332 + {^GIT_(AUTHOR|COMMITTER)_DATE$} {
3333 + append msg " - $name\n"
3334 + incr ignored_env
3335 + }
3336 + {^GIT_(AUTHOR|COMMITTER)_(NAME|EMAIL)$} {
3337 + append msg " - $name\n"
3338 + incr ignored_env
3339 + set suggest_user $name
3340 + }
3341 + }
3342 + }
3343 + if {$ignored_env > 0} {
3344 + append msg "
3345 +This is due to a known issue with the
3346 +Tcl binary distributed by Cygwin."
3347 +
3348 + if {$suggest_user ne {}} {
3349 + append msg "
3350 +
3351 +A good replacement for $suggest_user
3352 +is placing values for the user.name and
3353 +user.email settings into your personal
3354 +~/.gitconfig file.
3355 +"
3356 + }
3357 + warn_popup $msg
3358 + }
3359 + unset ignored_env msg suggest_user name
3360 +}
3361 +
3362 if {!$single_commit} {
3363 load_all_remotes
3364 populate_fetch_menu .mbar.fetch