aboutsummaryrefslogtreecommitdiff
path: root/path.c
diff options
context:
space:
mode:
authorDevin Lehmacher <lehmacdj@gmail.com>2017-03-13 16:43:54 -0400
committerJunio C Hamano <gitster@pobox.com>2017-03-13 14:39:36 -0700
commite7f136bf93132c24183c168a9a054540e6216c06 (patch)
treeb5ee63d508156d6a420bdc2a5acaf253f4ea1694 /path.c
parentd6db3f216544d05e09159756812ccbcb16861d71 (diff)
downloadgit-e7f136bf93132c24183c168a9a054540e6216c06.tar.gz
git-e7f136bf93132c24183c168a9a054540e6216c06.tar.xz
path.c: add xdg_cache_home
We already have xdg_config_home to format paths relative to XDG_CONFIG_HOME. Let's provide a similar function xdg_cache_home to do the same for paths relative to XDG_CACHE_HOME. Signed-off-by: Devin Lehmacher <lehmacdj@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'path.c')
-rw-r--r--path.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/path.c b/path.c
index efcedafba..22248436b 100644
--- a/path.c
+++ b/path.c
@@ -1272,6 +1272,21 @@ char *xdg_config_home(const char *filename)
return NULL;
}
+char *xdg_cache_home(const char *filename)
+{
+ const char *home, *cache_home;
+
+ assert(filename);
+ cache_home = getenv("XDG_CACHE_HOME");
+ if (cache_home && *cache_home)
+ return mkpathdup("%s/git/%s", cache_home, filename);
+
+ home = getenv("HOME");
+ if (home)
+ return mkpathdup("%s/.cache/git/%s", home, filename);
+ return NULL;
+}
+
GIT_PATH_FUNC(git_path_cherry_pick_head, "CHERRY_PICK_HEAD")
GIT_PATH_FUNC(git_path_revert_head, "REVERT_HEAD")
GIT_PATH_FUNC(git_path_squash_msg, "SQUASH_MSG")