git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Johannes Schindelin <johannes.schindelin@gmx.de>
Date
Oct 30, 2015, 19:10 UTC
Message-ID
<alpine.DEB.1.00.1510302010010.31610@s15462909.onlinehome-server.info>
In-Reply-To
<cover.1443619795.git.johannes.schindelin@gmx.de>

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(-)
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
Previous: Johannes Schindelin
Message 2 of 2 in “git-gui: fix detection of Cygwin”
  1. 1/2 git-gui: fix detection of CygwinJohannes Schindelin, Oct 30, 2015
  2. 2/2 git-gui (Windows): use git-gui.exe in `Create Desktop Shortcut`Johannes Schindelin, Oct 30, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.