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

2 messages from 2014-03-18 to 2014-03-18. Participants: Astril Hayato, Junio C Hamano.
Thread: https://gitlist.dev/t/36207

## Astril Hayato, 2014-03-18 17:53

Subject: [PATCH v2] Documentation/gitk: Document new config file location
Message-ID: <1395165187-3629-1-git-send-email-astrilhayato@gmail.com>
URL: https://gitlist.dev/e/1395165187-3629-1-git-send-email-astrilhayato%40gmail.com

```
User config file location now complies with XDG base directory specification

Signed-off-by: Astril Hayato <astrilhayato@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

```

## Junio C Hamano, 2014-03-18 20:07

Subject: Re: [PATCH v2] Documentation/gitk: Document new config file location
Message-ID: <xmqqr45z6zj7.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqqr45z6zj7.fsf%40gitster.dls.corp.google.com
In-Reply-To: <1395165187-3629-1-git-send-email-astrilhayato@gmail.com>

```
Astril Hayato <astrilhayato@gmail.com> writes:

> User config file location now complies with XDG base directory specification
>
> Signed-off-by: Astril Hayato <astrilhayato@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.

The last line is a bit of a lie, isn't it?

If XDG_CONFIG_HOME is set to an non-empty string, config_file is set
to $XDG_CONFIG_HOME/git/gitk.  Otherwise config_file is set to
$HOME/.config/git/gitk.

After that happens:

 - if that file exists, it is used;

 - otherwise:

   . if $HOME/.gitk exists, we use it (in other words, $HOME/.gitk
     is never used unless the user is an old timer who has one);

   . if $HOME/.gitk does not exist (in other words, if none of the
     above exists), then an empty $config_file is created and used.

We use either $HOME/.config/git/gitk or $XDG_CONFIG_HOME/git/gitk
and never $HOME/.gitk when none of the above exists, and the choice
between the two depends on XDG_CONFIG_HOME.

I'll queue this patch as-is, but we may want to further clarify with
a follow-up patch.

Thanks.

```
