path: root/builtin/config.c
diff options
authorHuynh Khoi Nguyen Nguyen <>2012-06-22 09:03:26 (GMT)
committerJunio C Hamano <>2012-06-25 16:06:15 (GMT)
commit0e8593dc5b812df00400347e88f5707225fe831e (patch)
tree68be684a7a46815589337e28743371b3c862288c /builtin/config.c
parent684e40f657ae004d60dfa833567bec4a409d78f9 (diff)
config: write to $XDG_CONFIG_HOME/git/config file when appropriate
Teach git to write to $XDG_CONFIG_HOME/git/config if - it already exists, - $HOME/.gitconfig file doesn't, and - The --global option is used. Otherwise, write to $HOME/.gitconfig when the --global option is given, as before. If the user doesn'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 <> Signed-off-by: Valentin Duperray <> Signed-off-by: Franck Jonas <> Signed-off-by: Lucien Kong <> Signed-off-by: Thomas Nguy <> Signed-off-by: Matthieu Moy <> Signed-off-by: Junio C Hamano <>
Diffstat (limited to 'builtin/config.c')
1 files changed, 1 insertions, 4 deletions
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 ||
+ 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;