format-patch: support format.mboxrd with --stdout
mboxrd is a more robust output format when used with --stdout and needs more exposure. Introducing this config knob lets users choose the more robust format for all their --stdout uses. Relying on --pretty=mboxrd and including all of pretty-formats.txt in the `git format-patch' documentation would likely be confusing to users. Furthermore, this setting is useful across multiple invocations. So introduce `format.mboxrd' as a boolean configuration knob that changes the default --pretty=email format to --pretty=mboxrd when (and only when) --stdout is in use. Signed-off-by: Eric Wong <e@80x24.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
7c2ef319c5
commit
4810946f60
@ -52,6 +52,7 @@ static int decoration_style;
|
||||
static int decoration_given;
|
||||
static int use_mailmap_config = 1;
|
||||
static unsigned int force_in_body_from;
|
||||
static int stdout_mboxrd;
|
||||
static const char *fmt_patch_subject_prefix = "PATCH";
|
||||
static int fmt_patch_name_max = FORMAT_PATCH_NAME_MAX_DEFAULT;
|
||||
static const char *fmt_pretty;
|
||||
@ -1077,6 +1078,10 @@ static int git_format_config(const char *var, const char *value, void *cb)
|
||||
cover_from_description_mode = parse_cover_from_description(value);
|
||||
return 0;
|
||||
}
|
||||
if (!strcmp(var, "format.mboxrd")) {
|
||||
stdout_mboxrd = git_config_bool(var, value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
return git_log_config(var, value, cb);
|
||||
}
|
||||
@ -2105,6 +2110,9 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
|
||||
rev.diffopt.close_file, "--output",
|
||||
!!output_directory, "--output-directory");
|
||||
|
||||
if (use_stdout && stdout_mboxrd)
|
||||
rev.commit_format = CMIT_FMT_MBOXRD;
|
||||
|
||||
if (use_stdout) {
|
||||
setup_pager();
|
||||
} else if (!rev.diffopt.close_file) {
|
||||
|
Reference in New Issue
Block a user