format-patch: make "-p" suppress diffstat
Once upon a time, format-patch would use its default stat plus patch format only when no diff format was given on the command line. This meant that "format-patch -p" would suppress the stat and show just the patch. Commit68daa64changed this to keep the stat format when we had an "implicit" patch format, like "-U5". As a side effect, this meant that an explicit patch format was now ignored (because cmd_format_patch didn't know the reason that the format was set way down in diff_opt_parse). This patch unbreaks what68daa64did (while still preserving what68daa64was trying to do), reinstating "-p" to suppress the default behavior. We do this by parsing "-p" ourselves in format-patch, and noting whether it was used explicitly. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
78d553b7d7
commit
1d46f2ea14
@ -891,6 +891,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
|
||||
struct patch_ids ids;
|
||||
char *add_signoff = NULL;
|
||||
struct strbuf buf = STRBUF_INIT;
|
||||
int use_patch_format = 0;
|
||||
const struct option builtin_format_patch_options[] = {
|
||||
{ OPTION_CALLBACK, 'n', "numbered", &numbered, NULL,
|
||||
"use [PATCH n/m] even with a single patch",
|
||||
@ -920,6 +921,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
|
||||
PARSE_OPT_NOARG | PARSE_OPT_NONEG, keep_callback },
|
||||
OPT_BOOLEAN(0, "no-binary", &no_binary_diff,
|
||||
"don't output binary diffs"),
|
||||
OPT_BOOLEAN('p', NULL, &use_patch_format,
|
||||
"show patch format instead of default (patch + stat)"),
|
||||
OPT_BOOLEAN(0, "ignore-if-in-upstream", &ignore_if_in_upstream,
|
||||
"don't include a patch matching a commit upstream"),
|
||||
OPT_GROUP("Messaging"),
|
||||
@ -1027,8 +1030,10 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
|
||||
if (argc > 1)
|
||||
die ("unrecognized argument: %s", argv[1]);
|
||||
|
||||
if (!rev.diffopt.output_format
|
||||
|| rev.diffopt.output_format == DIFF_FORMAT_PATCH)
|
||||
if (use_patch_format)
|
||||
rev.diffopt.output_format |= DIFF_FORMAT_PATCH;
|
||||
else if (!rev.diffopt.output_format ||
|
||||
rev.diffopt.output_format == DIFF_FORMAT_PATCH)
|
||||
rev.diffopt.output_format = DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_SUMMARY | DIFF_FORMAT_PATCH;
|
||||
|
||||
if (!DIFF_OPT_TST(&rev.diffopt, TEXT) && !no_binary_diff)
|
||||
|
||||
Reference in New Issue
Block a user