git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthieu Moy <Matthieu.Moy@imag.fr>
To: git@vger.kernel.org, gitster@pobox.com
Cc: Matthieu Moy <Matthieu.Moy@imag.fr>
Subject: [PATCH] config: allow ~/ and ~user/ in include.path value
Date: Tue, 24 Apr 2012 13:08:09 +0200	[thread overview]
Message-ID: <1335265689-2270-1-git-send-email-Matthieu.Moy@imag.fr> (raw)


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

             reply	other threads:[~2012-04-24 11:08 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-24 11:08 Matthieu Moy [this message]
2012-04-24 18:33 ` [PATCH v2] config: allow ~/ and ~user/ in include.path value 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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1335265689-2270-1-git-send-email-Matthieu.Moy@imag.fr \
    --to=matthieu.moy@imag.fr \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).