aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJohannes Sixt <j6t@kdbg.org>2025-07-31 19:20:22 +0200
committerJohannes Sixt <j6t@kdbg.org>2025-07-31 19:20:22 +0200
commitf91175ea646a97e6fff8c6ae75eaed41d591a416 (patch)
treebffed0be3853a0ec8a1f10ccfbda4ed95e7c8f85
parent436dad00c5a717d56bf4feb8a1f5d39126579fe6 (diff)
parent158800ac9c792b875b2cd138a1ecbfb14fa6a71a (diff)
downloadgit-f91175ea646a97e6fff8c6ae75eaed41d591a416.tar.gz
Merge branch 'ml/windows-tie-loose-ends'
* ml/windows-tie-loose-ends: git-gui: use /cmd/git-gui.exe for shortcut git-gui: Windows tk_getSaveFile is not useful for shortcuts git-gui: let nice work on Windows git-gui: do not add directories to PATH on Windows Signed-off-by: Johannes Sixt <j6t@kdbg.org>
-rwxr-xr-xgit-gui.sh8
-rw-r--r--lib/shortcut.tcl52
-rwxr-xr-xwindows/git-gui.sh12
3 files changed, 35 insertions, 37 deletions
diff --git a/git-gui.sh b/git-gui.sh
index 8bb121db4f..d4b1d95d63 100755
--- a/git-gui.sh
+++ b/git-gui.sh
@@ -83,12 +83,6 @@ if {[is_Windows]} {
set _path_sep {:}
}
-if {[is_Windows]} {
- set gitguidir [file dirname [info script]]
- regsub -all ";" $gitguidir "\\;" gitguidir
- set env(PATH) "$gitguidir;$env(PATH)"
-}
-
set _search_path {}
set _path_seen [dict create]
foreach p [split $env(PATH) $_path_sep] {
@@ -575,8 +569,6 @@ proc _lappend_nice {cmd_var} {
set _nice [_which nice]
if {[catch {safe_exec [list $_nice git version]}]} {
set _nice {}
- } elseif {[is_Windows] && [file dirname $_nice] ne [file dirname $::_git]} {
- set _nice {}
}
}
if {$_nice ne {}} {
diff --git a/lib/shortcut.tcl b/lib/shortcut.tcl
index 1d01d9cbfa..431665059e 100644
--- a/lib/shortcut.tcl
+++ b/lib/shortcut.tcl
@@ -3,27 +3,41 @@
proc do_windows_shortcut {} {
global _gitworktree
- set fn [tk_getSaveFile \
- -parent . \
- -title [mc "%s (%s): Create Desktop Icon" [appname] [reponame]] \
- -initialfile "Git [reponame].lnk"]
- if {$fn != {}} {
- if {[file extension $fn] ne {.lnk}} {
- set fn ${fn}.lnk
- }
- # Use git-gui.exe if available (ie: git-for-windows)
- set cmdLine [list [_which git-gui]]
- if {$cmdLine eq {}} {
- set cmdLine [list [info nameofexecutable] \
- [file normalize $::argv0]]
- }
- if {[catch {
- win32_create_lnk $fn $cmdLine \
- [file normalize $_gitworktree]
- } err]} {
- error_popup [strcat [mc "Cannot write shortcut:"] "\n\n$err"]
+
+ set desktop [safe_exec [list cygpath -mD]]
+ set link_file "Git [reponame].lnk"
+ set link_path [file normalize [file join $desktop $link_file]]
+
+ # on Windows, tk_getSaveFile dereferences .lnk files, so no simple
+ # filename chooser is available. Use the default or quit.
+ if {[file exists $link_path]} {
+ set answer [tk_messageBox \
+ -type yesno \
+ -title [mc "%s (%s): Create Desktop Icon" [appname] [reponame]] \
+ -default yes \
+ -message [mc "Replace existing shortcut: %s?" $link_file]]
+ if {$answer == no} {
+ return
}
}
+
+ # Use git-gui.exe if found, fall back to wish + launcher
+ set link_arguments {}
+ set link_target [safe_exec [list cygpath -m /cmd/git-gui.exe]]
+ if {![file executable $link_target]} {
+ set link_target [_which git-gui]
+ }
+ if {![file executable $link_target]} {
+ set link_target [file normalize [info nameofexecutable]]
+ set link_arguments [file normalize $::argv0]
+ }
+ set cmdLine [list $link_target $link_arguments]
+ if {[catch {
+ win32_create_lnk $link_path $cmdLine \
+ [file normalize $_gitworktree]
+ } err]} {
+ error_popup [strcat [mc "Cannot write shortcut:"] "\n\n$err"]
+ }
}
proc do_cygwin_shortcut {} {
diff --git a/windows/git-gui.sh b/windows/git-gui.sh
index b1845c5055..38debe376c 100755
--- a/windows/git-gui.sh
+++ b/windows/git-gui.sh
@@ -13,13 +13,5 @@ if { $argc >=2 && [lindex $argv 0] == "--working-dir" } {
incr argc -2
}
-set basedir [file dirname \
- [file dirname \
- [file dirname [info script]]]]
-set bindir [file join $basedir bin]
-set bindir "$bindir;[file join $basedir mingw bin]"
-regsub -all ";" $bindir "\\;" bindir
-set env(PATH) "$bindir;$env(PATH)"
-unset bindir
-
-source [file join [file dirname [info script]] git-gui.tcl]
+set thisdir [file normalize [file dirname [info script]]]
+source [file join $thisdir git-gui.tcl]