Skip to content

Commit 7145c65

Browse files
mark987prati0100
authored andcommitted
git-gui - remove obsolete Cygwin specific code
In the current git release, git-gui runs on Cygwin without enabling any of git-gui's Cygwin specific code. This happens as the Cygwin specific code in git-gui was (mostly) written in 2007-2008 to work with Cygwin's then supplied Tcl/Tk which was an incompletely ported variant of the 8.4.1 Windows Tcl/Tk code. In March, 2012, that 8.4.1 package was replaced with a full port based upon the upstream unix/X11 code, since maintained up to date. The two Tcl/Tk packages are completely incompatible, and have different signatures. When Cygwin's Tcl/Tk signature changed in 2012, git-gui no longer detected Cygwin, so did not enable Cygwin specific code, and the POSIX environment provided by Cygwin since 2012 supported git-gui as a generic unix. Thus, no-one apparently noticed the existence of incompatible Cygwin specific code. However, since commit c5766ea in the git-gui source tree (https://github.com/prati0100/git-gui, master at a5005de), and not yet pulled into the git repository, the is_Cygwin function does detect Cygwin using the unix/X11 Tcl/Tk. The Cygwin specific code is enabled, causing use of Windows rather than unix pathnames, and enabling incorrect warnings about environment variables that were relevant only to the old Tcl/Tk. The end result is that (upstream) git-gui is now incompatible with Cygwin. So, delete Cygwin specific code (code protected by "if is_Cygwin") that is not needed in any form to work with the unix/X11 Tcl/Tk. Cygwin specific code required to enable file browsing and shortcut creation is not addressed in this patch, does not currently work, and invocation of those items may leave git-gui in a confused state. Signed-off-by: Mark Levedahl <[email protected]> Acked-by: Johannes Schindelin <[email protected]> Signed-off-by: Pratyush Yadav <[email protected]>
1 parent ae49066 commit 7145c65

File tree

2 files changed

+7
-134
lines changed

2 files changed

+7
-134
lines changed

git-gui.sh

Lines changed: 6 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -84,14 +84,7 @@ proc _which {what args} {
8484
global env _search_exe _search_path
8585

8686
if {$_search_path eq {}} {
87-
if {[is_Cygwin] && [regexp {^(/|\.:)} $env(PATH)]} {
88-
set _search_path [split [exec cygpath \
89-
--windows \
90-
--path \
91-
--absolute \
92-
$env(PATH)] {;}]
93-
set _search_exe .exe
94-
} elseif {[is_Windows]} {
87+
if {[is_Windows]} {
9588
set gitguidir [file dirname [info script]]
9689
regsub -all ";" $gitguidir "\\;" gitguidir
9790
set env(PATH) "$gitguidir;$env(PATH)"
@@ -342,14 +335,7 @@ proc gitexec {args} {
342335
if {[catch {set _gitexec [git --exec-path]} err]} {
343336
error "Git not installed?\n\n$err"
344337
}
345-
if {[is_Cygwin]} {
346-
set _gitexec [exec cygpath \
347-
--windows \
348-
--absolute \
349-
$_gitexec]
350-
} else {
351-
set _gitexec [file normalize $_gitexec]
352-
}
338+
set _gitexec [file normalize $_gitexec]
353339
}
354340
if {$args eq {}} {
355341
return $_gitexec
@@ -364,14 +350,7 @@ proc githtmldir {args} {
364350
# Git not installed or option not yet supported
365351
return {}
366352
}
367-
if {[is_Cygwin]} {
368-
set _githtmldir [exec cygpath \
369-
--windows \
370-
--absolute \
371-
$_githtmldir]
372-
} else {
373-
set _githtmldir [file normalize $_githtmldir]
374-
}
353+
set _githtmldir [file normalize $_githtmldir]
375354
}
376355
if {$args eq {}} {
377356
return $_githtmldir
@@ -1318,9 +1297,6 @@ if {$_gitdir eq "."} {
13181297
set _gitdir [pwd]
13191298
}
13201299

1321-
if {![file isdirectory $_gitdir] && [is_Cygwin]} {
1322-
catch {set _gitdir [exec cygpath --windows $_gitdir]}
1323-
}
13241300
if {![file isdirectory $_gitdir]} {
13251301
catch {wm withdraw .}
13261302
error_popup [strcat [mc "Git directory not found:"] "\n\n$_gitdir"]
@@ -1332,11 +1308,7 @@ apply_config
13321308

13331309
# v1.7.0 introduced --show-toplevel to return the canonical work-tree
13341310
if {[package vcompare $_git_version 1.7.0] >= 0} {
1335-
if { [is_Cygwin] } {
1336-
catch {set _gitworktree [exec cygpath --windows [git rev-parse --show-toplevel]]}
1337-
} else {
1338-
set _gitworktree [git rev-parse --show-toplevel]
1339-
}
1311+
set _gitworktree [git rev-parse --show-toplevel]
13401312
} else {
13411313
# try to set work tree from environment, core.worktree or use
13421314
# cdup to obtain a relative path to the top of the worktree. If
@@ -1561,24 +1533,8 @@ proc rescan {after {honor_trustmtime 1}} {
15611533
}
15621534
}
15631535

1564-
if {[is_Cygwin]} {
1565-
set is_git_info_exclude {}
1566-
proc have_info_exclude {} {
1567-
global is_git_info_exclude
1568-
1569-
if {$is_git_info_exclude eq {}} {
1570-
if {[catch {exec test -f [gitdir info exclude]}]} {
1571-
set is_git_info_exclude 0
1572-
} else {
1573-
set is_git_info_exclude 1
1574-
}
1575-
}
1576-
return $is_git_info_exclude
1577-
}
1578-
} else {
1579-
proc have_info_exclude {} {
1580-
return [file readable [gitdir info exclude]]
1581-
}
1536+
proc have_info_exclude {} {
1537+
return [file readable [gitdir info exclude]]
15821538
}
15831539

15841540
proc rescan_stage2 {fd after} {
@@ -3112,10 +3068,6 @@ if {[is_MacOSX]} {
31123068
set doc_path [githtmldir]
31133069
if {$doc_path ne {}} {
31143070
set doc_path [file join $doc_path index.html]
3115-
3116-
if {[is_Cygwin]} {
3117-
set doc_path [exec cygpath --mixed $doc_path]
3118-
}
31193071
}
31203072

31213073
if {[file isfile $doc_path]} {
@@ -4087,60 +4039,6 @@ set file_lists($ui_workdir) [list]
40874039
wm title . "[appname] ([reponame]) [file normalize $_gitworktree]"
40884040
focus -force $ui_comm
40894041

4090-
# -- Warn the user about environmental problems. Cygwin's Tcl
4091-
# does *not* pass its env array onto any processes it spawns.
4092-
# This means that git processes get none of our environment.
4093-
#
4094-
if {[is_Cygwin]} {
4095-
set ignored_env 0
4096-
set suggest_user {}
4097-
set msg [mc "Possible environment issues exist.
4098-
4099-
The following environment variables are probably
4100-
going to be ignored by any Git subprocess run
4101-
by %s:
4102-
4103-
" [appname]]
4104-
foreach name [array names env] {
4105-
switch -regexp -- $name {
4106-
{^GIT_INDEX_FILE$} -
4107-
{^GIT_OBJECT_DIRECTORY$} -
4108-
{^GIT_ALTERNATE_OBJECT_DIRECTORIES$} -
4109-
{^GIT_DIFF_OPTS$} -
4110-
{^GIT_EXTERNAL_DIFF$} -
4111-
{^GIT_PAGER$} -
4112-
{^GIT_TRACE$} -
4113-
{^GIT_CONFIG$} -
4114-
{^GIT_(AUTHOR|COMMITTER)_DATE$} {
4115-
append msg " - $name\n"
4116-
incr ignored_env
4117-
}
4118-
{^GIT_(AUTHOR|COMMITTER)_(NAME|EMAIL)$} {
4119-
append msg " - $name\n"
4120-
incr ignored_env
4121-
set suggest_user $name
4122-
}
4123-
}
4124-
}
4125-
if {$ignored_env > 0} {
4126-
append msg [mc "
4127-
This is due to a known issue with the
4128-
Tcl binary distributed by Cygwin."]
4129-
4130-
if {$suggest_user ne {}} {
4131-
append msg [mc "
4132-
4133-
A good replacement for %s
4134-
is placing values for the user.name and
4135-
user.email settings into your personal
4136-
~/.gitconfig file.
4137-
" $suggest_user]
4138-
}
4139-
warn_popup $msg
4140-
}
4141-
unset ignored_env msg suggest_user name
4142-
}
4143-
41444042
# -- Only initialize complex UI if we are going to stay running.
41454043
#
41464044
if {[is_enabled transport]} {

lib/choose_repository.tcl

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -174,9 +174,6 @@ constructor pick {} {
174174
-foreground blue \
175175
-underline 1
176176
set home $::env(HOME)
177-
if {[is_Cygwin]} {
178-
set home [exec cygpath --windows --absolute $home]
179-
}
180177
set home "[file normalize $home]/"
181178
set hlen [string length $home]
182179
foreach p $sorted_recent {
@@ -374,18 +371,6 @@ proc _objdir {path} {
374371
return $objdir
375372
}
376373

377-
if {[is_Cygwin]} {
378-
set objdir [file join $path .git objects.lnk]
379-
if {[file isfile $objdir]} {
380-
return [win32_read_lnk $objdir]
381-
}
382-
383-
set objdir [file join $path objects.lnk]
384-
if {[file isfile $objdir]} {
385-
return [win32_read_lnk $objdir]
386-
}
387-
}
388-
389374
return {}
390375
}
391376

@@ -623,12 +608,6 @@ method _do_clone2 {} {
623608
}
624609

625610
set giturl $origin_url
626-
if {[is_Cygwin] && [file isdirectory $giturl]} {
627-
set giturl [exec cygpath --unix --absolute $giturl]
628-
if {$clone_type eq {shared}} {
629-
set objdir [exec cygpath --unix --absolute $objdir]
630-
}
631-
}
632611

633612
if {[file exists $local_path]} {
634613
error_popup [mc "Location %s already exists." $local_path]
@@ -668,11 +647,7 @@ method _do_clone2 {} {
668647
fconfigure $f_cp -translation binary -encoding binary
669648
cd $objdir
670649
while {[gets $f_in line] >= 0} {
671-
if {[is_Cygwin]} {
672-
puts $f_cp [exec cygpath --unix --absolute $line]
673-
} else {
674-
puts $f_cp [file normalize $line]
675-
}
650+
puts $f_cp [file normalize $line]
676651
}
677652
close $f_in
678653
close $f_cp

0 commit comments

Comments
 (0)