git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] config: allow ~/ and ~user/ in include.path value
@ 2012-04-24 11:08 Matthieu Moy
  2012-04-24 18:33 ` [PATCH v2] " Matthieu Moy
  0 siblings, 1 reply; 6+ messages in thread
From: Matthieu Moy @ 2012-04-24 11:08 UTC (permalink / raw)
  To: git, gitster; +Cc: Matthieu Moy


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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-04-26  6:19 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-04-24 11:08 [PATCH] config: allow ~/ and ~user/ in include.path value Matthieu Moy
2012-04-24 18:33 ` [PATCH v2] " Matthieu Moy
2012-04-25 12:00   ` Jeff King
2012-04-25 15:53     ` Matthieu Moy
2012-04-25 20:14     ` Junio C Hamano
2012-04-26  6:19       ` Jeff King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).