Skip to content

Commit c930764

Browse files
committed
git-gui (Windows): use git-gui.exe in Create Desktop Shortcut
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 #448 Signed-off-by: Johannes Schindelin <[email protected]>
1 parent fae3fe7 commit c930764

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

git-gui/lib/shortcut.tcl

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,17 @@ proc do_windows_shortcut {} {
1111
if {[file extension $fn] ne {.lnk}} {
1212
set fn ${fn}.lnk
1313
}
14+
# Use /cmd/git-gui.exe if available
15+
set normalized [file normalize $::argv0]
16+
regsub "/mingw../libexec/git-core/git-gui$" \
17+
$normalized "/cmd/git-gui.exe" cmdLine
18+
if {$cmdLine != $normalized && [file exists $cmdLine]} {
19+
set cmdLine [list [file nativename $cmdLine]]
20+
} else {
21+
set cmdLine [list [info nameofexecutable] $normalized]
22+
}
1423
if {[catch {
15-
win32_create_lnk $fn [list \
16-
[info nameofexecutable] \
17-
[file normalize $::argv0] \
18-
] \
24+
win32_create_lnk $fn $cmdLine \
1925
[file normalize $_gitworktree]
2026
} err]} {
2127
error_popup [strcat [mc "Cannot write shortcut:"] "\n\n$err"]

0 commit comments

Comments
 (0)