summaryrefslogtreecommitdiff
path: root/path.c
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2015-05-11 14:24:01 -0700
committerJunio C Hamano <gitster@pobox.com>2015-05-11 14:24:01 -0700
commit558e5a8c40944a6a952c7e15dab648b922e0bd02 (patch)
tree0416da7b9ef7b43c3d5e5bf766507b43735db5d3 /path.c
parent7cb5073fcaffe8a8c0572fdffb332110b0eaae69 (diff)
parent846e5dfbab5d5a0a85252c1400dc0371e02e75a8 (diff)
downloadgit-558e5a8c40944a6a952c7e15dab648b922e0bd02.tar.gz
Merge branch 'pt/xdg-config-path'
Code clean-up for xdg configuration path support. * pt/xdg-config-path: path.c: remove home_config_paths() git-config: replace use of home_config_paths() git-commit: replace use of home_config_paths() credential-store.c: replace home_config_paths() with xdg_config_home() dir.c: replace home_config_paths() with xdg_config_home() attr.c: replace home_config_paths() with xdg_config_home() path.c: implement xdg_config_home()
Diffstat (limited to 'path.c')
-rw-r--r--path.c43
1 files changed, 15 insertions, 28 deletions
diff --git a/path.c b/path.c
index 586f2c90a3..10f4cbf6b7 100644
--- 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;
+}