Re: [PATCHv6 4/4] Write to $XDG_CONFIG_HOME/git/config file
- From
David Aguilar <davvid@gmail.com>
- Date
- Jun 9, 2012, 03:48 UTC
- Message-ID
- <CAJDDKr6sCrwy99-5-sOaAuNjYmnw73CicF3PyYMe8hvf38oFvg@mail.gmail.com>
- In-Reply-To
- <1338988885-21933-4-git-send-email-Huynh-Khoi-Nguyen.Nguyen@ensimag.imag.fr>
On Wed, Jun 6, 2012 at 6:21 AM, Huynh Khoi Nguyen NGUYEN <Huynh-Khoi-Nguyen.Nguyen@ensimag.imag.fr> wrote:
Show 22 quoted lines
> From: NGUYEN Huynh Khoi Nguyen <nguyenhu@ensibm.imag.fr> > > Git will be able to write to $XDG_CONFIG_HOME/git/config, a new > configuration file following XDG specification, if: > - this file already exists, and > - $HOME/.gitconfig file doesn't, and > - global option is used. > Otherwise Git writes to $HOME/.gitconfig with global option, as usual. > If you don't create $XDG_CONFIG_HOME/git/config, there is ABSOLUTELY > NO change. Users can use this new file ONLY if they want. > If $XDG_CONFIG_HOME is either not set or empty, $HOME/.config/git/config > will be used. > Advice for users who often come back to an old version of GIT: > you shouldn't create this file. > > Signed-off-by: Huynh Khoi Nguyen NGUYEN <Huynh-Khoi-Nguyen.Nguyen@ensimag.imag.fr> > Signed-off-by: Valentin Duperray <Valentin.Duperray@ensimag.imag.fr> > Signed-off-by: Franck Jonas <Franck.Jonas@ensimag.imag.fr> > Signed-off-by: Lucien Kong <Lucien.Kong@ensimag.imag.fr> > Signed-off-by: Thomas Nguy <Thomas.Nguy@ensimag.imag.fr> > Signed-off-by: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr> > ---
I'm all for this change too.
I did a little research RE: the OSX and Windows question.
glib makes no differentiation between OSX and Linux, but Windows does have its own #ifdef.
http://git.gnome.org/browse/glib/tree/glib/gutils.c#n1251
I certainly don't think this should affect this series, I'm just noting it as something that the Windows folks might care about. Perhaps something for compat/ in the future?
The downside to doing the same as glib is more documentation. The upside is... consistency?
Thanks, David
Show 76 quoted lines
> Documentation/git-config.txt | 3 ++- > builtin/config.c | 5 +---- > t/t1306-xdg-files.sh | 30 ++++++++++++++++++++++++++++++ > 3 files changed, 33 insertions(+), 5 deletions(-) > > diff --git a/Documentation/git-config.txt b/Documentation/git-config.txt > index 7e344a2..a2b4786 100644 > --- a/Documentation/git-config.txt > +++ b/Documentation/git-config.txt > @@ -97,7 +97,8 @@ OPTIONS > > --global:: > For writing options: write to global ~/.gitconfig file rather than > - the repository .git/config. > + the repository .git/config, write to $XDG_CONFIG_HOME/git/config file > + if this file exists and ~/.gitconfig file doesn't. > + > For reading options: read only from global ~/.gitconfig and from > $XDG_CONFIG_HOME/git/config rather than from all available files. > diff --git a/builtin/config.c b/builtin/config.c > index da54fd1..e8e1c0a 100644 > --- a/builtin/config.c > +++ b/builtin/config.c > @@ -387,10 +387,7 @@ int cmd_config(int argc, const char **argv, const char *prefix) > > home_config_paths(&user_config, &xdg_config, "config"); > > - if (access(user_config, R_OK) && !access(xdg_config, R_OK) && > - (actions == ACTION_LIST || > - actions == ACTION_GET_COLOR || > - actions == ACTION_GET_COLORBOOL)) > + if (access(user_config, R_OK) && !access(xdg_config, R_OK)) > given_config_file = xdg_config; > else if (user_config) > given_config_file = user_config; > diff --git a/t/t1306-xdg-files.sh b/t/t1306-xdg-files.sh > index eb0f40b..dbf236a 100755 > --- a/t/t1306-xdg-files.sh > +++ b/t/t1306-xdg-files.sh > @@ -154,4 +154,34 @@ test_expect_success 'Checking attributes in a non-XDG global attributes file' ' > ' > > > +test_expect_success 'write: xdg file exists and ~/.gitconfig doesn'\''t' ' > + mkdir -p .config/git && > + >.config/git/config && > + rm .gitconfig && > + git config --global user.name "write_config" && > + echo "[user]" >expected && > + echo " name = write_config" >>expected && > + test_cmp expected .config/git/config > +' > + > + > +test_expect_success 'write: xdg file exists and ~/.gitconfig exists' ' > + >.gitconfig && > + git config --global user.name "write_gitconfig" && > + echo "[user]" >expected && > + echo " name = write_gitconfig" >>expected && > + test_cmp expected .gitconfig > +' > + > + > +test_expect_success 'write: ~/.config/git/ exists and config file doesn'\''t' ' > + rm .gitconfig && > + rm .config/git/config && > + git config --global user.name "write_gitconfig" && > + echo "[user]" >expected && > + echo " name = write_gitconfig" >>expected && > + test_cmp expected .gitconfig > +' > + > + > test_done > -- > 1.7.8