{"thread":{"id":"35702","subject":"[PATCH v2] gitk: Comply with XDG base directory specification","startedAt":"2014-01-21T19:10:16Z","lastAt":"2014-01-22T11:08:07Z","messageCount":2,"participants":["Astril Hayato","Paul Mackerras"],"isPatch":true,"patchVersion":2,"patchTotal":null},"messages":[{"id":"233448","messageId":"1390331416-4662-1-git-send-email-astrilhayato@gmail.com","threadId":"35702","inReplyTo":null,"subject":"[PATCH v2] gitk: Comply with XDG base directory specification","fromName":"Astril Hayato","fromEmail":"astrilhayato@gmail.com","sentAt":"2014-01-21T19:10:16Z","receivedAt":"2014-01-21T19:10:16Z","isPatch":true,"sender":{"key":"astrilhayato@gmail.com","avatar":null},"body":"Write the gitk config data to $XDG_CONFIG_HOME/git/gitk ($HOME/.config/git/gitk\nby default) in line with the XDG specification. This makes it consistent with\ngit which also follows the spec.\n\nIf $HOME/.gitk already exists use that for backward compatibility, so only new\ninstallations are affected.\n\nSigned-off-by: Astril Hayato <astrilhayato@gmail.com>\n---\n gitk | 35 ++++++++++++++++++++++++++++++-----\n 1 file changed, 30 insertions(+), 5 deletions(-)\n\ndiff --git a/gitk b/gitk\nindex 33c3a6c..d592d7e 100755\n--- a/gitk\n+++ b/gitk\n@@ -2761,14 +2761,17 @@ proc savestuff {w} {\n     global linkfgcolor circleoutlinecolor\n     global autoselect autosellen extdifftool perfile_attrs markbgcolor use_ttk\n     global hideremotes want_ttk maxrefs\n+    global config_file config_file_tmp\n \n     if {$stuffsaved} return\n     if {![winfo viewable .]} return\n     catch {\n-\tif {[file exists ~/.gitk-new]} {file delete -force ~/.gitk-new}\n-\tset f [open \"~/.gitk-new\" w]\n+\tif {[file exists $config_file_tmp]} {\n+\t    file delete -force $config_file_tmp\n+\t}\n+\tset f [open $config_file_tmp w]\n \tif {$::tcl_platform(platform) eq {windows}} {\n-\t    file attributes \"~/.gitk-new\" -hidden true\n+\t    file attributes $config_file_tmp -hidden true\n \t}\n \tputs $f [list set mainfont $mainfont]\n \tputs $f [list set textfont $textfont]\n@@ -2845,7 +2848,7 @@ proc savestuff {w} {\n \t}\n \tputs $f \"}\"\n \tclose $f\n-\tfile rename -force \"~/.gitk-new\" \"~/.gitk\"\n+\tfile rename -force $config_file_tmp $config_file\n     }\n     set stuffsaved 1\n }\n@@ -12058,7 +12061,29 @@ namespace import ::msgcat::mc\n ## And eventually load the actual message catalog\n ::msgcat::mcload $gitk_msgsdir\n \n-catch {source ~/.gitk}\n+catch {\n+    # follow the XDG base directory specification by default. See\n+    # http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html\n+    if {[info exists env(XDG_CONFIG_HOME)] && $env(XDG_CONFIG_HOME) ne \"\"} {\n+\t# XDG_CONFIG_HOME environment variable is set\n+\tset config_file [file join $env(XDG_CONFIG_HOME) git gitk]\n+\tset config_file_tmp [file join $env(XDG_CONFIG_HOME) git gitk-tmp]\n+    } else {\n+\t# default XDG_CONFIG_HOME\n+\tset config_file \"~/.config/git/gitk\"\n+\tset config_file_tmp \"~/.config/git/gitk-tmp\"\n+    }\n+    if {![file exists $config_file]} {\n+\t# for backward compatibility use the old config file if it exists\n+\tif {[file exists \"~/.gitk\"]} {\n+\t    set config_file \"~/.gitk\"\n+\t    set config_file_tmp \"~/.gitk-tmp\"\n+\t} elseif {![file exists [file dirname $config_file]]} {\n+\t    file mkdir [file dirname $config_file]\n+\t}\n+    }\n+    source $config_file\n+}\n \n parsefont mainfont $mainfont\n eval font create mainfont [fontflags mainfont]\n-- \n1.8.5.3\n"},{"id":"233503","messageId":"20140122110806.GC7306@iris.ozlabs.ibm.com","threadId":"35702","inReplyTo":"1390331416-4662-1-git-send-email-astrilhayato@gmail.com","subject":"Re: [PATCH v2] gitk: Comply with XDG base directory specification","fromName":"Paul Mackerras","fromEmail":"paulus@samba.org","sentAt":"2014-01-22T11:08:07Z","receivedAt":"2014-01-22T11:08:07Z","isPatch":true,"sender":{"key":"paulus@samba.org","avatar":"https://avatars.githubusercontent.com/u/1606439?v=4"},"body":"On Tue, Jan 21, 2014 at 07:10:16PM +0000, Astril Hayato wrote:\n> Write the gitk config data to $XDG_CONFIG_HOME/git/gitk ($HOME/.config/git/gitk\n> by default) in line with the XDG specification. This makes it consistent with\n> git which also follows the spec.\n> \n> If $HOME/.gitk already exists use that for backward compatibility, so only new\n> installations are affected.\n> \n> Signed-off-by: Astril Hayato <astrilhayato@gmail.com>\n\nThanks, applied.\n\nPaul.\n"}]}