summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cache.h7
-rw-r--r--path.c13
2 files changed, 17 insertions, 3 deletions
diff --git a/cache.h b/cache.h
index ba04ff8bd3..2a0fb3e4ba 100644
--- a/cache.h
+++ b/cache.h
@@ -1288,6 +1288,13 @@ int looks_like_command_line_option(const char *str);
/**
* Return a newly allocated string with the evaluation of
+ * "$XDG_CONFIG_HOME/$subdir/$filename" if $XDG_CONFIG_HOME is non-empty, otherwise
+ * "$HOME/.config/$subdir/$filename". Return NULL upon error.
+ */
+char *xdg_config_home_for(const char *subdir, const char *filename);
+
+/**
+ * Return a newly allocated string with the evaluation of
* "$XDG_CONFIG_HOME/git/$filename" if $XDG_CONFIG_HOME is non-empty, otherwise
* "$HOME/.config/git/$filename". Return NULL upon error.
*/
diff --git a/path.c b/path.c
index 7bccd830e9..1b1de3be09 100644
--- a/path.c
+++ b/path.c
@@ -1503,21 +1503,28 @@ int looks_like_command_line_option(const char *str)
return str && str[0] == '-';
}
-char *xdg_config_home(const char *filename)
+char *xdg_config_home_for(const char *subdir, const char *filename)
{
const char *home, *config_home;
+ assert(subdir);
assert(filename);
config_home = getenv("XDG_CONFIG_HOME");
if (config_home && *config_home)
- return mkpathdup("%s/git/%s", config_home, filename);
+ return mkpathdup("%s/%s/%s", config_home, subdir, filename);
home = getenv("HOME");
if (home)
- return mkpathdup("%s/.config/git/%s", home, filename);
+ return mkpathdup("%s/.config/%s/%s", home, subdir, filename);
+
return NULL;
}
+char *xdg_config_home(const char *filename)
+{
+ return xdg_config_home_for("git", filename);
+}
+
char *xdg_cache_home(const char *filename)
{
const char *home, *cache_home;