Skip to content

Commit 1d01592

Browse files
committed
gitk: Tcl9 doesn't expand ~, use $env(HOME)
gitk looks for configuration files under $(HOME)/.., and uses the typical shortcut formats to find this, e.g., ~/.config/. This relies upon Tcl expanding such constructs to replace ~ with $(HOME). But, Tcl 9 has stopped doing that for various reasons, and now supplies [file tildeexpand ...] to perform this expansion. There are a very few places that need this expansion, and all must be modified regardless of appraoch taken. POSIX specifies that $HOME be defined at the time of login, and both Cygwin and MSYS (underlying git for windows) set this variable. Tcl8 uses pwnam to look up the underlying database record on Unix, but will get the same result as using $HOME on any POSIX compliant system. On Windows, Tcl just accesses $HOME, falling back to other environment variables if $HOME is not set. Git for Windows has $HOME defined by MSYS, so this works just as on the others. As $env(HOME) works in Tcl 8 and 9, while anything using [file tildeexpand ... ] will not, let's use the simpler approah as doing so adds no lines of code. Signed-off-by: Mark Levedahl <[email protected]>
1 parent 0f4b70c commit 1d01592

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

gitk

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12625,14 +12625,14 @@ catch {
1262512625
set config_file_tmp [file join $env(XDG_CONFIG_HOME) git gitk-tmp]
1262612626
} else {
1262712627
# default XDG_CONFIG_HOME
12628-
set config_file "~/.config/git/gitk"
12629-
set config_file_tmp "~/.config/git/gitk-tmp"
12628+
set config_file "$env(HOME)/.config/git/gitk"
12629+
set config_file_tmp "$env(HOME)/.config/git/gitk-tmp"
1263012630
}
1263112631
if {![file exists $config_file]} {
1263212632
# for backward compatibility use the old config file if it exists
12633-
if {[file exists "~/.gitk"]} {
12634-
set config_file "~/.gitk"
12635-
set config_file_tmp "~/.gitk-tmp"
12633+
if {[file exists "$env(HOME)/.gitk"]} {
12634+
set config_file "$env(HOME)/.gitk"
12635+
set config_file_tmp "$env(HOME)/.gitk-tmp"
1263612636
} elseif {![file exists [file dirname $config_file]]} {
1263712637
file mkdir [file dirname $config_file]
1263812638
}

0 commit comments

Comments
 (0)