git-commit: replace use of home_config_paths()
[gitweb.git] / path.c
diff --git a/path.c b/path.c
index 757d0b057d3d72842e182864cc0f52b6457e4079..4edc1eb8680a63a6eff8c3a910748d195565a32b 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);
 }
@@ -854,3 +856,18 @@ int is_ntfs_dotgit(const char *name)
                        len = -1;
                }
 }
+
+char *xdg_config_home(const char *filename)
+{
+       const char *home, *config_home;
+
+       assert(filename);
+       config_home = getenv("XDG_CONFIG_HOME");
+       if (config_home && *config_home)
+               return mkpathdup("%s/git/%s", config_home, filename);
+
+       home = getenv("HOME");
+       if (home)
+               return mkpathdup("%s/.config/git/%s", home, filename);
+       return NULL;
+}