提交 8f863398 编写于 作者: A Astril Hayato 提交者: Paul Mackerras

gitk: Comply with XDG base directory specification

Write the gitk config data to $XDG_CONFIG_HOME/git/gitk ($HOME/.config/git/gitk
by default) in line with the XDG specification. This makes it consistent with
git which also follows the spec.

If $HOME/.gitk already exists use that for backward compatibility, so only new
installations are affected.
Signed-off-by: NAstril Hayato <astrilhayato@gmail.com>
Signed-off-by: NPaul Mackerras <paulus@samba.org>
上级 786f15c8
...@@ -2787,14 +2787,17 @@ proc savestuff {w} { ...@@ -2787,14 +2787,17 @@ proc savestuff {w} {
global linkfgcolor circleoutlinecolor global linkfgcolor circleoutlinecolor
global autoselect autosellen extdifftool perfile_attrs markbgcolor use_ttk global autoselect autosellen extdifftool perfile_attrs markbgcolor use_ttk
global hideremotes want_ttk maxrefs global hideremotes want_ttk maxrefs
global config_file config_file_tmp
if {$stuffsaved} return if {$stuffsaved} return
if {![winfo viewable .]} return if {![winfo viewable .]} return
catch { catch {
if {[file exists ~/.gitk-new]} {file delete -force ~/.gitk-new} if {[file exists $config_file_tmp]} {
set f [open "~/.gitk-new" w] file delete -force $config_file_tmp
}
set f [open $config_file_tmp w]
if {$::tcl_platform(platform) eq {windows}} { if {$::tcl_platform(platform) eq {windows}} {
file attributes "~/.gitk-new" -hidden true file attributes $config_file_tmp -hidden true
} }
puts $f [list set mainfont $mainfont] puts $f [list set mainfont $mainfont]
puts $f [list set textfont $textfont] puts $f [list set textfont $textfont]
...@@ -2871,7 +2874,7 @@ proc savestuff {w} { ...@@ -2871,7 +2874,7 @@ proc savestuff {w} {
} }
puts $f "}" puts $f "}"
close $f close $f
file rename -force "~/.gitk-new" "~/.gitk" file rename -force $config_file_tmp $config_file
} }
set stuffsaved 1 set stuffsaved 1
} }
...@@ -12084,7 +12087,29 @@ namespace import ::msgcat::mc ...@@ -12084,7 +12087,29 @@ namespace import ::msgcat::mc
## And eventually load the actual message catalog ## And eventually load the actual message catalog
::msgcat::mcload $gitk_msgsdir ::msgcat::mcload $gitk_msgsdir
catch {source ~/.gitk} catch {
# follow the XDG base directory specification by default. See
# http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
if {[info exists env(XDG_CONFIG_HOME)] && $env(XDG_CONFIG_HOME) ne ""} {
# XDG_CONFIG_HOME environment variable is set
set config_file [file join $env(XDG_CONFIG_HOME) git gitk]
set config_file_tmp [file join $env(XDG_CONFIG_HOME) git gitk-tmp]
} else {
# default XDG_CONFIG_HOME
set config_file "~/.config/git/gitk"
set config_file_tmp "~/.config/git/gitk-tmp"
}
if {![file exists $config_file]} {
# for backward compatibility use the old config file if it exists
if {[file exists "~/.gitk"]} {
set config_file "~/.gitk"
set config_file_tmp "~/.gitk-tmp"
} elseif {![file exists [file dirname $config_file]]} {
file mkdir [file dirname $config_file]
}
}
source $config_file
}
parsefont mainfont $mainfont parsefont mainfont $mainfont
eval font create mainfont [fontflags mainfont] eval font create mainfont [fontflags mainfont]
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册