{"thread":{"id":"35527","subject":"[PATCH] gitk: Comply with XDG base directory specification","startedAt":"2013-12-13T19:46:36Z","lastAt":"2014-01-21T17:40:58Z","messageCount":3,"participants":["Astril Hayato","Paul Mackerras"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"231979","messageId":"1386963996-5481-1-git-send-email-astrilhayato@gmail.com","threadId":"35527","inReplyTo":null,"subject":"[PATCH] gitk: Comply with XDG base directory specification","fromName":"Astril Hayato","fromEmail":"astrilhayato@gmail.com","sentAt":"2013-12-13T19:46:36Z","receivedAt":"2013-12-13T19:46:36Z","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 | 33 ++++++++++++++++++++++++++++-----\n 1 file changed, 28 insertions(+), 5 deletions(-)\n\ndiff --git a/gitk b/gitk\nindex 33c3a6c..34dd4a6 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,27 @@ 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+\tif {![file exists [file dirname $config_file]]} {\n+\t    file mkdir [file dirname $config_file]\n+\t}\n+\t# for backward compatability use the old config file if it exists\n+\tif {[file exists \"~/.gitk\"]} {set config_file \"~/.gitk\"}\n+    }\n+    source $config_file\n+}\n \n parsefont mainfont $mainfont\n eval font create mainfont [fontflags mainfont]\n-- \n1.8.5.1\n"},{"id":"233437","messageId":"20140121111041.GC8265@iris.ozlabs.ibm.com","threadId":"35527","inReplyTo":"1386963996-5481-1-git-send-email-astrilhayato@gmail.com","subject":"Re: [PATCH] gitk: Comply with XDG base directory specification","fromName":"Paul Mackerras","fromEmail":"paulus@samba.org","sentAt":"2014-01-21T11:10:41Z","receivedAt":"2014-01-21T11:10:41Z","isPatch":true,"sender":{"key":"paulus@samba.org","avatar":"https://avatars.githubusercontent.com/u/1606439?v=4"},"body":"On Fri, Dec 13, 2013 at 07:46:36PM +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\nSounds reasonable...\n\n> @@ -12058,7 +12061,27 @@ 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> +\tif {![file exists [file dirname $config_file]]} {\n> +\t    file mkdir [file dirname $config_file]\n> +\t}\n> +\t# for backward compatability use the old config file if it exists\n> +\tif {[file exists \"~/.gitk\"]} {set config_file \"~/.gitk\"}\n\nDon't we need to set config_file_tmp here too?\n\nAnd, do we really want to create the ~/.config/git directory if we are\nusing the old-style ~/.gitk as the config file?\n\nPaul.\n"},{"id":"233445","messageId":"CAFysofbwxb23or25vqh_JFLNU7Ksm9ch=YnvaFggPvdU_x2T7A@mail.gmail.com","threadId":"35527","inReplyTo":"20140121111041.GC8265@iris.ozlabs.ibm.com","subject":"Re: [PATCH] gitk: Comply with XDG base directory specification","fromName":"Astril Hayato","fromEmail":"astrilhayato@gmail.com","sentAt":"2014-01-21T17:40:58Z","receivedAt":"2014-01-21T17:40:58Z","isPatch":true,"sender":{"key":"astrilhayato@gmail.com","avatar":null},"body":"On Tue, Jan 21, 2014 at 11:10 AM, Paul Mackerras <paulus@samba.org> wrote:\n>> +    if {![file exists $config_file]} {\n>> +     if {![file exists [file dirname $config_file]]} {\n>> +         file mkdir [file dirname $config_file]\n>> +     }\n>> +     # for backward compatability use the old config file if it exists\n>> +     if {[file exists \"~/.gitk\"]} {set config_file \"~/.gitk\"}\n>\n> Don't we need to set config_file_tmp here too?\n\nYeah it's probably best to keep the two files together.\n\n>\n> And, do we really want to create the ~/.config/git directory if we are\n> using the old-style ~/.gitk as the config file?\n\nProbably not. I'll prepare a new patch restoring the old behaviour.\n\nRegards,\nAstril.\n"}]}