Skip to content

Commit f91175e

Browse files
committed
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 <[email protected]>
2 parents 436dad0 + 158800a commit f91175e

File tree

3 files changed

+35
-37
lines changed

3 files changed

+35
-37
lines changed

git-gui.sh

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,6 @@ if {[is_Windows]} {
8383
set _path_sep {:}
8484
}
8585

86-
if {[is_Windows]} {
87-
set gitguidir [file dirname [info script]]
88-
regsub -all ";" $gitguidir "\\;" gitguidir
89-
set env(PATH) "$gitguidir;$env(PATH)"
90-
}
91-
9286
set _search_path {}
9387
set _path_seen [dict create]
9488
foreach p [split $env(PATH) $_path_sep] {
@@ -575,8 +569,6 @@ proc _lappend_nice {cmd_var} {
575569
set _nice [_which nice]
576570
if {[catch {safe_exec [list $_nice git version]}]} {
577571
set _nice {}
578-
} elseif {[is_Windows] && [file dirname $_nice] ne [file dirname $::_git]} {
579-
set _nice {}
580572
}
581573
}
582574
if {$_nice ne {}} {

lib/shortcut.tcl

Lines changed: 33 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3,27 +3,41 @@
33

44
proc do_windows_shortcut {} {
55
global _gitworktree
6-
set fn [tk_getSaveFile \
7-
-parent . \
8-
-title [mc "%s (%s): Create Desktop Icon" [appname] [reponame]] \
9-
-initialfile "Git [reponame].lnk"]
10-
if {$fn != {}} {
11-
if {[file extension $fn] ne {.lnk}} {
12-
set fn ${fn}.lnk
13-
}
14-
# Use git-gui.exe if available (ie: git-for-windows)
15-
set cmdLine [list [_which git-gui]]
16-
if {$cmdLine eq {}} {
17-
set cmdLine [list [info nameofexecutable] \
18-
[file normalize $::argv0]]
19-
}
20-
if {[catch {
21-
win32_create_lnk $fn $cmdLine \
22-
[file normalize $_gitworktree]
23-
} err]} {
24-
error_popup [strcat [mc "Cannot write shortcut:"] "\n\n$err"]
6+
7+
set desktop [safe_exec [list cygpath -mD]]
8+
set link_file "Git [reponame].lnk"
9+
set link_path [file normalize [file join $desktop $link_file]]
10+
11+
# on Windows, tk_getSaveFile dereferences .lnk files, so no simple
12+
# filename chooser is available. Use the default or quit.
13+
if {[file exists $link_path]} {
14+
set answer [tk_messageBox \
15+
-type yesno \
16+
-title [mc "%s (%s): Create Desktop Icon" [appname] [reponame]] \
17+
-default yes \
18+
-message [mc "Replace existing shortcut: %s?" $link_file]]
19+
if {$answer == no} {
20+
return
2521
}
2622
}
23+
24+
# Use git-gui.exe if found, fall back to wish + launcher
25+
set link_arguments {}
26+
set link_target [safe_exec [list cygpath -m /cmd/git-gui.exe]]
27+
if {![file executable $link_target]} {
28+
set link_target [_which git-gui]
29+
}
30+
if {![file executable $link_target]} {
31+
set link_target [file normalize [info nameofexecutable]]
32+
set link_arguments [file normalize $::argv0]
33+
}
34+
set cmdLine [list $link_target $link_arguments]
35+
if {[catch {
36+
win32_create_lnk $link_path $cmdLine \
37+
[file normalize $_gitworktree]
38+
} err]} {
39+
error_popup [strcat [mc "Cannot write shortcut:"] "\n\n$err"]
40+
}
2741
}
2842

2943
proc do_cygwin_shortcut {} {

windows/git-gui.sh

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,5 @@ if { $argc >=2 && [lindex $argv 0] == "--working-dir" } {
1313
incr argc -2
1414
}
1515

16-
set basedir [file dirname \
17-
[file dirname \
18-
[file dirname [info script]]]]
19-
set bindir [file join $basedir bin]
20-
set bindir "$bindir;[file join $basedir mingw bin]"
21-
regsub -all ";" $bindir "\\;" bindir
22-
set env(PATH) "$bindir;$env(PATH)"
23-
unset bindir
24-
25-
source [file join [file dirname [info script]] git-gui.tcl]
16+
set thisdir [file normalize [file dirname [info script]]]
17+
source [file join $thisdir git-gui.tcl]

0 commit comments

Comments
 (0)