home_config_paths(): let the caller ignore xdg path
authorMatthieu Moy <Matthieu.Moy@imag.fr>
Fri, 25 Jul 2014 19:11:35 +0000 (21:11 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 25 Jul 2014 19:23:08 +0000 (12:23 -0700)
The caller can signal that it is not interested in learning
the location of $HOME/.gitconfig by passing global=NULL, but
there is no way to decline the path to the configuration
file based on $XDG_CONFIG_HOME.

Allow the caller to pass xdg=NULL to signal that it is not
interested in the XDG location.

Commit-message-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
path.c
diff --git a/path.c b/path.c
index c36f00393007dc2d48a7b7fd765d809fb224d8a4..1b6cdc407f4fddee1b3593f27ec03a643511fe46 100644 (file)
--- a/path.c
+++ b/path.c
@@ -148,10 +148,12 @@ void home_config_paths(char **global, char **xdg, char *file)
                        *global = mkpathdup("%s/.gitconfig", home);
        }
 
-       if (!xdg_home)
-               *xdg = NULL;
-       else
-               *xdg = mkpathdup("%s/git/%s", xdg_home, file);
+       if (xdg) {
+               if (!xdg_home)
+                       *xdg = NULL;
+               else
+                       *xdg = mkpathdup("%s/git/%s", xdg_home, file);
+       }
 
        free(to_free);
 }