We don't need an mbox when generating a file with just a single message. And tools tools such as "git am" and "git send-email" already handle a bare email rather than an mbox just fine. Users wanting to manually insert the output into an MUA are not likely to want an mbox-formatted file either. Finally, git's current mbox formatting is not robust, (does not yet deal well with a commit message containing a line matching "^From "). For all of these reasons, it's better to just generate an email message rather than an mbox when generating a file with a single message. Note that "format-patch --stdout" will still use the (less than totally robust) mbox format, even if there is only a single commit. This is because "git rebase" uses "format-patch --stdout" with "am --rebasing" which looks at the generated "From " line to find the commit identifier that is embedded there. Signed-off-by: Carl Worth <cworth@xxxxxxxxxx> --- This is as recently discussed by myself and H. Peter Anvin on the list. Note that I originally claimed that git-send-email would need to be updated to support this mode, but I found that it actually already has the necessary code. Also, this patch doesn't add any new test cases only because the test suite seems to provide good coverange of "git format-patch" usage already, (generating and using both mbox and non-mbox output after this patch). Indeed the test suite showed me a problem I had with "git rebase" in an early version of this patch. builtin/log.c | 4 +++- log-tree.c | 6 ++++-- revision.h | 3 ++- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/builtin/log.c b/builtin/log.c index 976e16f..adbec9f 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -1205,7 +1205,9 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) get_patch_ids(&rev, &ids, prefix); } - if (!use_stdout) + if (use_stdout) + rev.format_mbox = 1; + else realstdout = xfdopen(xdup(1), "w"); if (prepare_revision_walk(&rev)) diff --git a/log-tree.c b/log-tree.c index d3ae969..6aab273 100644 --- a/log-tree.c +++ b/log-tree.c @@ -217,8 +217,10 @@ void log_write_email_headers(struct rev_info *opt, struct commit *commit, subject = "Subject: "; } - printf("From %s Mon Sep 17 00:00:00 2001\n", name); - graph_show_oneline(opt->graph); + if (opt->format_mbox) { + printf("From %s Mon Sep 17 00:00:00 2001\n", name); + graph_show_oneline(opt->graph); + } if (opt->message_id) { printf("Message-Id: <%s>\n", opt->message_id); graph_show_oneline(opt->graph); diff --git a/revision.h b/revision.h index 568f1c9..10cc747 100644 --- a/revision.h +++ b/revision.h @@ -88,7 +88,8 @@ struct rev_info { abbrev_commit:1, use_terminator:1, missing_newline:1, - date_mode_explicit:1; + date_mode_explicit:1, + format_mbox:1; unsigned int disable_stdin:1; enum date_mode date_mode; -- 1.7.0.4 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html