format-patch: Always generate a patch
Jeff King recently reinstated -p to suppress the default diffstat
(as -p used to work before 68daa64
, about 14 months ago).
However, -p is also needed in combination with certain options
(e.g. --stat or --numstat) in order to produce any patch at all.
The documentation does not mention this.
Since the purpose of format-patch is to produce a patch that
can be emailed, it does not make sense that certain combination
of options will suppress the generation of the patch itself.
Therefore:
* Update 'git format-patch' to always generate a patch.
* Since the --name-only, --name-status, and --check suppresses
the generation of the patch, disallow those options,
and remove the description of them in the documentation.
* Remove the reference to -p in the description of -U.
* Remove the descriptions of the options that are synonyms for -p
plus another option (--patch-with-raw and --patch-with-stat).
* While at it, slightly tweak the description of -p itself
to say that it generates "plain patches", so that you can
think of -p as "plain patch" as an mnemonic aid.
Signed-off-by: Björn Gustavsson <bgustavsson@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
1d46f2ea14
commit
02bc5b03f5
@ -921,10 +921,10 @@ 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_BOOLEAN('p', NULL, &use_patch_format,
|
||||
"show patch format instead of default (patch + stat)"),
|
||||
OPT_GROUP("Messaging"),
|
||||
{ OPTION_CALLBACK, 0, "add-header", NULL, "header",
|
||||
"add email header", PARSE_OPT_NONEG,
|
||||
@ -1030,11 +1030,20 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
|
||||
if (argc > 1)
|
||||
die ("unrecognized argument: %s", argv[1]);
|
||||
|
||||
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 (rev.diffopt.output_format & DIFF_FORMAT_NAME)
|
||||
die("--name-only does not make sense");
|
||||
if (rev.diffopt.output_format & DIFF_FORMAT_NAME_STATUS)
|
||||
die("--name-status does not make sense");
|
||||
if (rev.diffopt.output_format & DIFF_FORMAT_CHECKDIFF)
|
||||
die("--check does not make sense");
|
||||
|
||||
if (!use_patch_format &&
|
||||
(!rev.diffopt.output_format ||
|
||||
rev.diffopt.output_format == DIFF_FORMAT_PATCH))
|
||||
rev.diffopt.output_format = DIFF_FORMAT_DIFFSTAT | DIFF_FORMAT_SUMMARY;
|
||||
|
||||
/* Always generate a patch */
|
||||
rev.diffopt.output_format |= DIFF_FORMAT_PATCH;
|
||||
|
||||
if (!DIFF_OPT_TST(&rev.diffopt, TEXT) && !no_binary_diff)
|
||||
DIFF_OPT_SET(&rev.diffopt, BINARY);
|
||||
|
Reference in New Issue
Block a user