summaryrefslogtreecommitdiff
path: root/config.c
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2012-04-25 12:00:36 (GMT)
committerJunio C Hamano <gitster@pobox.com>2012-04-30 00:46:32 (GMT)
commit4c0a89fcde219df8db8fdb9635ef2ef40d002a6e (patch)
treebc2f0008d9770ff20e56b0baf3e096cdf2230e01 /config.c
parente8dde3e5f9ddb7cf95a6ff3cea6cf07c3a2db80d (diff)
downloadgit-4c0a89fcde219df8db8fdb9635ef2ef40d002a6e.zip
git-4c0a89fcde219df8db8fdb9635ef2ef40d002a6e.tar.gz
git-4c0a89fcde219df8db8fdb9635ef2ef40d002a6e.tar.bz2
config: expand tildes in include.path variable
You can already use relative paths in include.path, which means that including "foo" from your global "~/.gitconfig" will look in your home directory. However, you might want to do something clever like putting "~/.gitconfig-foo" in a specific repository's config file. Signed-off-by: Jeff King <peff@peff.net> Acked-by: Matthieu Moy <Matthieu.Moy@imag.fr> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'config.c')
-rw-r--r--config.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/config.c b/config.c
index 68d3294..2bbf02d 100644
--- a/config.c
+++ b/config.c
@@ -37,6 +37,11 @@ static int handle_path_include(const char *path, struct config_include_data *inc
{
int ret = 0;
struct strbuf buf = STRBUF_INIT;
+ char *expanded = expand_user_path(path);
+
+ if (!expanded)
+ return error("Could not expand include path '%s'", path);
+ path = expanded;
/*
* Use an absolute path as-is, but interpret relative paths
@@ -63,6 +68,7 @@ static int handle_path_include(const char *path, struct config_include_data *inc
inc->depth--;
}
strbuf_release(&buf);
+ free(expanded);
return ret;
}