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 c5766eae6f in the git-gui source tree (https://github.com/prati0100/git-gui, master at a5005ded), 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 <mlevedahl@gmail.com> Acked-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Pratyush Yadav <me@yadavpratyush.com>

Mark Levedahl committed Jun 26, 2023 at 12:53 UTC 7145c654fffecd1f3d4a2b8bf05755ce262903e8
2 files changed +7 -134
git-gui.sh
+6 -108
@@ -84,14 +84,7 @@ proc _which {what args} {
84 global env _search_exe _search_path
85
86 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]} {
88 set gitguidir [file dirname [info script]]
89 regsub -all ";" $gitguidir "\\;" gitguidir
90 set env(PATH) "$gitguidir;$env(PATH)"
@@ -342,14 +335,7 @@ proc gitexec {args} {
335 if {[catch {set _gitexec [git --exec-path]} err]} {
336 error "Git not installed?\n\n$err"
337 }
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]
339 }
340 if {$args eq {}} {
341 return $_gitexec
@@ -364,14 +350,7 @@ proc githtmldir {args} {
350 # Git not installed or option not yet supported
351 return {}
352 }
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]
354 }
355 if {$args eq {}} {
356 return $_githtmldir
@@ -1318,9 +1297,6 @@ if {$_gitdir eq "."} {
1297 set _gitdir [pwd]
1298 }
1299
1321 -if {![file isdirectory $_gitdir] && [is_Cygwin]} {
1322 - catch {set _gitdir [exec cygpath --windows $_gitdir]}
1323 -}
1300 if {![file isdirectory $_gitdir]} {
1301 catch {wm withdraw .}
1302 error_popup [strcat [mc "Git directory not found:"] "\n\n$_gitdir"]
@@ -1332,11 +1308,7 @@ apply_config
1308
1309 # v1.7.0 introduced --show-toplevel to return the canonical work-tree
1310 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]
1312 } else {
1313 # try to set work tree from environment, core.worktree or use
1314 # cdup to obtain a relative path to the top of the worktree. If
@@ -1561,24 +1533,8 @@ proc rescan {after {honor_trustmtime 1}} {
1533 }
1534 }
1535
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]]
1538 }
1539
1540 proc rescan_stage2 {fd after} {
@@ -3112,10 +3068,6 @@ if {[is_MacOSX]} {
3068 set doc_path [githtmldir]
3069 if {$doc_path ne {}} {
3070 set doc_path [file join $doc_path index.html]
3115 -
3116 - if {[is_Cygwin]} {
3117 - set doc_path [exec cygpath --mixed $doc_path]
3118 - }
3071 }
3072
3073 if {[file isfile $doc_path]} {
@@ -4087,60 +4039,6 @@ set file_lists($ui_workdir) [list]
4039 wm title . "[appname] ([reponame]) [file normalize $_gitworktree]"
4040 focus -force $ui_comm
4041
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 -
4042 # -- Only initialize complex UI if we are going to stay running.
4043 #
4044 if {[is_enabled transport]} {
lib/choose_repository.tcl
+1 -26
@@ -174,9 +174,6 @@ constructor pick {} {
174 -foreground blue \
175 -underline 1
176 set home $::env(HOME)
177 - if {[is_Cygwin]} {
178 - set home [exec cygpath --windows --absolute $home]
179 - }
177 set home "[file normalize $home]/"
178 set hlen [string length $home]
179 foreach p $sorted_recent {
@@ -374,18 +371,6 @@ proc _objdir {path} {
371 return $objdir
372 }
373
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 -
374 return {}
375 }
376
@@ -623,12 +608,6 @@ method _do_clone2 {} {
608 }
609
610 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 - }
611
612 if {[file exists $local_path]} {
613 error_popup [mc "Location %s already exists." $local_path]
@@ -668,11 +647,7 @@ method _do_clone2 {} {
647 fconfigure $f_cp -translation binary -encoding binary
648 cd $objdir
649 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]
651 }
652 close $f_in
653 close $f_cp