path: root/builtin
diff options
authorJunio C Hamano <>2016-11-22 21:13:16 (GMT)
committerJunio C Hamano <>2016-11-22 21:13:16 (GMT)
commit3f0ec0687d95e0f53c899f964d769ca1846874da (patch)
treeb901b420c13d6839b577ce04b0f51d2a37feb903 /builtin
parent1310affe024fba407bff55dbe65cd6d670c8a32d (diff)
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 <>
Diffstat (limited to 'builtin')
1 files changed, 15 insertions, 4 deletions
diff --git a/builtin/mailinfo.c b/builtin/mailinfo.c
index f6df274..e3b62f2 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=<encoding> | -n] [--scissors | --no-scissors] <msg> <patch> < 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
- */
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);
+ free(msgfile);
+ free(patchfile);
return status;