threads / patch / 40679

patch, 2 partsgit-gui (Windows): use git-gui.exe in `Create Desktop Shortcut`

Subject: [PATCH 2/2] git-gui (Windows): use git-gui.exe in `Create Desktop Shortcut`

## tl;dr

2 messages between Oct 30, 2015 and Oct 30, 2015. Diffs are folded; open one to read it.

replies: 1people: 1as markdown or json

Johannes Schindelin· Oct 30, 2015, 19:09 UTC · lore

[PATCH 1/2] git-gui: fix detection of Cygwin

MSys2 might *look* like Cygwin, but it is *not* Cygwin... Unless it is run with `MSYSTEM=MSYS`, that is.

This change is backwards-compatible because MSys also used the MSYSTEM variable to determine whether to run in MSys or in MinGW mode. The only difference is that MSys does not support running in 64-bit mode at all.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 git-gui.sh | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
Show changes to git-gui.sh +4 −6
diff --git a/git-gui.sh b/git-gui.sh
index 11048c7..9038a4c 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -270,12 +270,10 @@ proc is_Windows {} {
 proc is_Cygwin {} {
 	global _iscygwin
 	if {$_iscygwin eq {}} {
-		if {$::tcl_platform(platform) eq {windows}} {
-			if {[catch {set p [exec cygpath --windir]} err]} {
-				set _iscygwin 0
-			} else {
-				set _iscygwin 1
-			}
+		if {$::tcl_platform(platform) eq {windows} &&
+				(![info exists ::env(MSYSTEM)] ||
+				 $::env(MSYSTEM) ne {MSYS})} {
+			set _iscygwin 1
 		} else {
 			set _iscygwin 0
 		}
-- 
2.5.3.windows.1.3.gc322723
Johannes Schindelin· Oct 30, 2015, 19:10 UTC · lore

When calling `Repository>Create Desktop Shortcut`, Git GUI assumes that it is okay to call `wish.exe` directly on Windows. However, in Git for Windows 2.x' context, that leaves several crucial environment variables uninitialized, resulting in a shortcut that does not work.

To fix those environment variable woes, Git for Windows comes with a convenient `git-gui.exe`, so let's just use it when it is available.

This fixes https://github.com/git-for-windows/git/issues/448
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
 lib/shortcut.tcl | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
Show changes to lib/shortcut.tcl +10 −4
diff --git a/lib/shortcut.tcl b/lib/shortcut.tcl
index 78878ef..715916b 100644
--- a/lib/shortcut.tcl
+++ b/lib/shortcut.tcl
@@ -11,11 +11,17 @@ proc do_windows_shortcut {} {
 		if {[file extension $fn] ne {.lnk}} {
 			set fn ${fn}.lnk
 		}
+		# Use /cmd/git-gui.exe if available
+		set normalized [file normalize $::argv0]
+		regsub "/mingw../libexec/git-core/git-gui$" \
+			$normalized "/cmd/git-gui.exe" cmdLine
+		if {$cmdLine != $normalized && [file exists $cmdLine]} {
+			set cmdLine [list [file nativename $cmdLine]]
+		} else {
+			set cmdLine [list [info nameofexecutable] $normalized]
+		}
 		if {[catch {
-				win32_create_lnk $fn [list \
-					[info nameofexecutable] \
-					[file normalize $::argv0] \
-					] \
+				win32_create_lnk $fn $cmdLine \
 					[file normalize $_gitworktree]
 			} err]} {
 			error_popup [strcat [mc "Cannot write shortcut:"] "\n\n$err"]
-- 
2.5.3.windows.1.3.gc322723

← back to recent threads