From 3f0ec0687d95e0f53c899f964d769ca1846874da Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 22 Nov 2016 13:13:16 -0800 Subject: mailinfo: read local configuration Since b9605bc4f2 ("config: only read .git/config from configured repos", 2016-09-12), we do not read from ".git/config" unless we know we are in a repository. "git mailinfo" however didn't do the repository discovery and instead relied on the old behaviour. This was mostly OK because it was merely run as a helper program by other porcelain scripts that first chdir's up to the root of the working tree. Teach the command to run a "gentle" version of repository discovery so that local configuration variables like mailinfo.scissors are honoured. Signed-off-by: Junio C Hamano --- builtin/mailinfo.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'builtin/mailinfo.c') diff --git a/builtin/mailinfo.c b/builtin/mailinfo.c index f6df274111..e3b62f2fc7 100644 --- a/builtin/mailinfo.c +++ b/builtin/mailinfo.c @@ -11,15 +11,20 @@ static const char mailinfo_usage[] = "git mailinfo [-k | -b] [-m | --message-id] [-u | --encoding= | -n] [--scissors | --no-scissors] < mail >info"; +static char *prefix_copy(const char *prefix, const char *filename) +{ + if (!prefix || is_absolute_path(filename)) + return xstrdup(filename); + return xstrdup(prefix_filename(prefix, strlen(prefix), filename)); +} + int cmd_mailinfo(int argc, const char **argv, const char *prefix) { const char *def_charset; struct mailinfo mi; int status; + char *msgfile, *patchfile; - /* NEEDSWORK: might want to do the optional .git/ directory - * discovery - */ setup_mailinfo(&mi); def_charset = get_commit_output_encoding(); @@ -54,8 +59,14 @@ int cmd_mailinfo(int argc, const char **argv, const char *prefix) mi.input = stdin; mi.output = stdout; - status = !!mailinfo(&mi, argv[1], argv[2]); + + msgfile = prefix_copy(prefix, argv[1]); + patchfile = prefix_copy(prefix, argv[2]); + + status = !!mailinfo(&mi, msgfile, patchfile); clear_mailinfo(&mi); + free(msgfile); + free(patchfile); return status; } -- cgit v1.2.3