Merge branch 'jc/plug-fmt-merge-msg-leak' into maint
[gitweb.git] / path.c
diff --git a/path.c b/path.c
index 595da81ca67096bae9592d9455bdade442b92628..6b537ccfff452b7fbbe41446c001c8fda0679bea 100644 (file)
--- a/path.c
+++ b/path.c
@@ -130,34 +130,6 @@ char *git_path(const char *fmt, ...)
        return ret;
 }
 
-void home_config_paths(char **global, char **xdg, char *file)
-{
-       char *xdg_home = getenv("XDG_CONFIG_HOME");
-       char *home = getenv("HOME");
-       char *to_free = NULL;
-
-       if (!home) {
-               if (global)
-                       *global = NULL;
-       } else {
-               if (!xdg_home) {
-                       to_free = mkpathdup("%s/.config", home);
-                       xdg_home = to_free;
-               }
-               if (global)
-                       *global = mkpathdup("%s/.gitconfig", home);
-       }
-
-       if (xdg) {
-               if (!xdg_home)
-                       *xdg = NULL;
-               else
-                       *xdg = mkpathdup("%s/git/%s", xdg_home, file);
-       }
-
-       free(to_free);
-}
-
 char *git_path_submodule(const char *path, const char *fmt, ...)
 {
        char *pathname = get_pathname();
@@ -851,3 +823,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;
+}