[PATCH v3] Documentation/gitk: Document new config file location

2014-03-20 Thread Astril Hayato
User config file location now complies with the XDG base directory specification

Signed-off-by: Astril Hayato astrilhay...@gmail.com
---
 Documentation/gitk.txt | 10 --
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/Documentation/gitk.txt b/Documentation/gitk.txt
index 1e9e38a..7e03fcc 100644
--- a/Documentation/gitk.txt
+++ b/Documentation/gitk.txt
@@ -166,8 +166,14 @@ gitk --max-count=100 --all \-- Makefile::
 
 Files
 -
-Gitk creates the .gitk file in your $HOME directory to store preferences
-such as display options, font, and colors.
+User configuration and preferences are stored at:
+
+* '$XDG_CONFIG_HOME/git/gitk' if it exists, otherwise
+* '$HOME/.gitk' if it exists
+
+If neither of the above exist then '$XDG_CONFIG_HOME/git/gitk' is created and
+used by default. If '$XDG_CONFIG_HOME' is not set it defaults to
+'$HOME/.config' in all cases.
 
 History
 ---
-- 
1.9.0

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] Documentation/gitk: Document new config file location

2014-03-18 Thread Astril Hayato
User config file location now complies with XDG base directory specification

Signed-off-by: Astril Hayato astrilhay...@gmail.com
---
 Documentation/gitk.txt | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/Documentation/gitk.txt b/Documentation/gitk.txt
index 1e9e38a..c2aa514 100644
--- a/Documentation/gitk.txt
+++ b/Documentation/gitk.txt
@@ -166,8 +166,13 @@ gitk --max-count=100 --all \-- Makefile::
 
 Files
 -
-Gitk creates the .gitk file in your $HOME directory to store preferences
-such as display options, font, and colors.
+User configuration and preferences are stored at (in order of priority):
+
+* '$XDG_CONFIG_HOME/git/gitk' if it exists and '$XDG_CONFIG_HOME' is set
+* '$HOME/.config/git/gitk' if it exists
+* '$HOME/.gitk' if it exists
+
+If none of the above exist then '$HOME/.config/git/gitk' is created and used 
by default.
 
 History
 ---
-- 
1.9.0

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] Documentation/gitk: Document new config file location

2014-03-16 Thread Astril Hayato
User configuration file is now stored at $XDG_CONFIG_HOME/git/gitk

Signed-off-by: Astril Hayato astrilhay...@gmail.com
---
 Documentation/gitk.txt | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Documentation/gitk.txt b/Documentation/gitk.txt
index 1e9e38a..417a707 100644
--- a/Documentation/gitk.txt
+++ b/Documentation/gitk.txt
@@ -166,8 +166,8 @@ gitk --max-count=100 --all \-- Makefile::
 
 Files
 -
-Gitk creates the .gitk file in your $HOME directory to store preferences
-such as display options, font, and colors.
+User configuration and preferences are stored at $XDG_CONFIG_HOME/git/gitk or
+$HOME/.config/git/gitk if $XDG_CONFIG_HOME is not set.
 
 History
 ---
-- 
1.9.0

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] gitk: Comply with XDG base directory specification

2014-01-21 Thread Astril Hayato
On Tue, Jan 21, 2014 at 11:10 AM, Paul Mackerras pau...@samba.org wrote:
 +if {![file exists $config_file]} {
 + if {![file exists [file dirname $config_file]]} {
 + file mkdir [file dirname $config_file]
 + }
 + # for backward compatability use the old config file if it exists
 + if {[file exists ~/.gitk]} {set config_file ~/.gitk}

 Don't we need to set config_file_tmp here too?

Yeah it's probably best to keep the two files together.


 And, do we really want to create the ~/.config/git directory if we are
 using the old-style ~/.gitk as the config file?

Probably not. I'll prepare a new patch restoring the old behaviour.

Regards,
Astril.
--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH v2] gitk: Comply with XDG base directory specification

2014-01-21 Thread Astril Hayato
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: Astril Hayato astrilhay...@gmail.com
---
 gitk | 35 ++-
 1 file changed, 30 insertions(+), 5 deletions(-)

diff --git a/gitk b/gitk
index 33c3a6c..d592d7e 100755
--- a/gitk
+++ b/gitk
@@ -2761,14 +2761,17 @@ proc savestuff {w} {
 global linkfgcolor circleoutlinecolor
 global autoselect autosellen extdifftool perfile_attrs markbgcolor use_ttk
 global hideremotes want_ttk maxrefs
+global config_file config_file_tmp
 
 if {$stuffsaved} return
 if {![winfo viewable .]} return
 catch {
-   if {[file exists ~/.gitk-new]} {file delete -force ~/.gitk-new}
-   set f [open ~/.gitk-new w]
+   if {[file exists $config_file_tmp]} {
+   file delete -force $config_file_tmp
+   }
+   set f [open $config_file_tmp w]
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 textfont $textfont]
@@ -2845,7 +2848,7 @@ proc savestuff {w} {
}
puts $f }
close $f
-   file rename -force ~/.gitk-new ~/.gitk
+   file rename -force $config_file_tmp $config_file
 }
 set stuffsaved 1
 }
@@ -12058,7 +12061,29 @@ namespace import ::msgcat::mc
 ## And eventually load the actual message catalog
 ::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
 eval font create mainfont [fontflags mainfont]
-- 
1.8.5.3

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] gitk: Comply with XDG base directory specification

2013-12-13 Thread Astril Hayato
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: Astril Hayato astrilhay...@gmail.com
---
 gitk | 33 -
 1 file changed, 28 insertions(+), 5 deletions(-)

diff --git a/gitk b/gitk
index 33c3a6c..34dd4a6 100755
--- a/gitk
+++ b/gitk
@@ -2761,14 +2761,17 @@ proc savestuff {w} {
 global linkfgcolor circleoutlinecolor
 global autoselect autosellen extdifftool perfile_attrs markbgcolor use_ttk
 global hideremotes want_ttk maxrefs
+global config_file config_file_tmp
 
 if {$stuffsaved} return
 if {![winfo viewable .]} return
 catch {
-   if {[file exists ~/.gitk-new]} {file delete -force ~/.gitk-new}
-   set f [open ~/.gitk-new w]
+   if {[file exists $config_file_tmp]} {
+   file delete -force $config_file_tmp
+   }
+   set f [open $config_file_tmp w]
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 textfont $textfont]
@@ -2845,7 +2848,7 @@ proc savestuff {w} {
}
puts $f }
close $f
-   file rename -force ~/.gitk-new ~/.gitk
+   file rename -force $config_file_tmp $config_file
 }
 set stuffsaved 1
 }
@@ -12058,7 +12061,27 @@ namespace import ::msgcat::mc
 ## And eventually load the actual message catalog
 ::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]} {
+   if {![file exists [file dirname $config_file]]} {
+   file mkdir [file dirname $config_file]
+   }
+   # for backward compatability use the old config file if it exists
+   if {[file exists ~/.gitk]} {set config_file ~/.gitk}
+}
+source $config_file
+}
 
 parsefont mainfont $mainfont
 eval font create mainfont [fontflags mainfont]
-- 
1.8.5.1

--
To unsubscribe from this list: send the line unsubscribe git in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html