[PATCH] config: allow ~/ and ~user/ in include.path value
Signed-off-by: Matthieu Moy <Matthieu.Moy@imag.fr>
---
config.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/config.c b/config.c
index bfe0c79..dd8b9bf 100644
--- a/config.c
+++ b/config.c
@@ -33,11 +33,14 @@ static const char include_depth_advice[] =
"from\n"
" %s\n"
"Do you have circular includes?";
-static int handle_path_include(const char *path, struct config_include_data *inc)
+static int handle_path_include(const char *raw_path, struct config_include_data *inc)
{
int ret = 0;
struct strbuf buf = STRBUF_INIT;
-
+ int must_free_path = 1;
+ char *path = expand_user_path(raw_path);
+ if (!path)
+ return error("Could not expand include path '%s'.", raw_path);
/*
* Use an absolute path as-is, but interpret relative paths
* based on the including config file.
@@ -52,6 +55,7 @@ static int handle_path_include(const char *path, struct config_include_data *inc
if (slash)
strbuf_add(&buf, cf->name, slash - cf->name + 1);
strbuf_addstr(&buf, path);
+ must_free_path = 0;
path = buf.buf;
}
@@ -63,6 +67,8 @@ static int handle_path_include(const char *path, struct config_include_data *inc
inc->depth--;
}
strbuf_release(&buf);
+ if (must_free_path)
+ free(path);
return ret;
}
--
1.7.10.235.gb2edec