verify_lock(): on errors, let the caller unlock the lock
[gitweb.git] / path.c
diff --git a/path.c b/path.c
index 586f2c90a3c0def34016a692a14e335a46c015ed..10f4cbf6b78607870461f21dd1cd0f7a2776bc49 100644 (file)
--- a/path.c
+++ b/path.c
@@ -224,34 +224,6 @@ const char *mkpath(const char *fmt, ...)
        return cleanup_path(pathname->buf);
 }
 
-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);
-}
-
 const char *git_path_submodule(const char *path, const char *fmt, ...)
 {
        struct strbuf *buf = get_pathname();
@@ -931,3 +903,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;
+}