mirror of
https://github.com/git/git.git
synced 2024-11-20 16:24:06 +01:00
git-gui: Worked around environment variable problems on Windows.
Apparently the Cygwin tclsh/wish executables don't pass the environment that they inherited onto any children that they invoke. This causes a problem for some users during 'git fetch' or 'git push' as critical environment variables like GIT_SSH and SSH_AUTH_SOCK aren't available to the git processes. So we work around this by forcing sh to start a login shell, thus reloading the user's environment, then cd to the current directory, and finally start the requested process. Of course this won't correctly handle any transient environment variables that were inherited but were not supplied by the user's login shell. Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
This commit is contained in:
parent
8c0ce43682
commit
cc4b1c0213
42
git-gui
42
git-gui
@ -92,7 +92,7 @@ proc update_status {{final Ready.}} {
|
||||
}
|
||||
|
||||
if {![$ui_comm edit modified]
|
||||
|| [string trim [$ui_comm get 0.0 end]] == {}} {
|
||||
|| [string trim [$ui_comm get 0.0 end]] == {}} {
|
||||
if {[load_message GITGUI_MSG]} {
|
||||
} elseif {[load_message MERGE_MSG]} {
|
||||
} elseif {[load_message SQUASH_MSG]} {
|
||||
@ -591,25 +591,19 @@ proc commit_stage2 {fd_wt curHEAD msg} {
|
||||
proc fetch_from {remote} {
|
||||
set w [new_console "fetch $remote" \
|
||||
"Fetching new changes from $remote"]
|
||||
set cmd [list | git fetch]
|
||||
lappend -v
|
||||
set cmd [list git fetch]
|
||||
lappend cmd -v
|
||||
lappend cmd $remote
|
||||
lappend cmd |& cat
|
||||
set fd_f [open $cmd r]
|
||||
fconfigure $fd_f -blocking 0 -translation auto
|
||||
fileevent $fd_f readable [list console_read $w $fd_f]
|
||||
console_exec $w $cmd
|
||||
}
|
||||
|
||||
proc push_to {remote} {
|
||||
set w [new_console "push $remote" \
|
||||
"Pushing changes to $remote"]
|
||||
set cmd [list | git push]
|
||||
set cmd [list git push]
|
||||
lappend -v
|
||||
lappend cmd $remote
|
||||
lappend cmd |& cat
|
||||
set fd_f [open $cmd r]
|
||||
fconfigure $fd_f -blocking 0 -translation auto
|
||||
fileevent $fd_f readable [list console_read $w $fd_f]
|
||||
console_exec $w $cmd
|
||||
}
|
||||
|
||||
######################################################################
|
||||
@ -1043,6 +1037,26 @@ proc new_console {short_title long_title} {
|
||||
return $w
|
||||
}
|
||||
|
||||
proc console_exec {w cmd} {
|
||||
global tcl_platform
|
||||
|
||||
# -- Windows tosses the enviroment when we exec our child.
|
||||
# But most users need that so we have to relogin. :-(
|
||||
#
|
||||
if {$tcl_platform(platform) == {windows}} {
|
||||
set cmd [list sh --login -c "cd \"[pwd]\" && [join $cmd { }]"]
|
||||
}
|
||||
|
||||
# -- Tcl won't let us redirect both stdout and stderr to
|
||||
# the same pipe. So pass it through cat...
|
||||
#
|
||||
set cmd [concat | $cmd |& cat]
|
||||
|
||||
set fd_f [open $cmd r]
|
||||
fconfigure $fd_f -blocking 0 -translation auto
|
||||
fileevent $fd_f readable [list console_read $w $fd_f]
|
||||
}
|
||||
|
||||
proc console_read {w fd} {
|
||||
$w.m.t conf -state normal
|
||||
while {[gets $fd line] >= 0} {
|
||||
@ -1050,6 +1064,7 @@ proc console_read {w fd} {
|
||||
$w.m.t insert end "\n"
|
||||
}
|
||||
$w.m.t conf -state disabled
|
||||
$w.m.t see end
|
||||
|
||||
if {[eof $fd]} {
|
||||
close $fd
|
||||
@ -1062,6 +1077,7 @@ proc console_read {w fd} {
|
||||
## ui commands
|
||||
|
||||
set starting_gitk_msg {Please wait... Starting gitk...}
|
||||
|
||||
proc do_gitk {} {
|
||||
global tcl_platform ui_status_value starting_gitk_msg
|
||||
|
||||
@ -1072,7 +1088,7 @@ proc do_gitk {} {
|
||||
}
|
||||
}
|
||||
|
||||
if {$tcl_platform(platform) == "windows"} {
|
||||
if {$tcl_platform(platform) == {windows}} {
|
||||
exec sh -c gitk &
|
||||
} else {
|
||||
exec gitk &
|
||||
|
Loading…
Reference in New Issue
Block a user