@@ -21,7 +21,7 @@ endif::git-format-patch[]
ifndef::git-format-patch[]
-p::
-u::
---patch::
+--[no-]patch::
Generate patch (see section titled
ifdef::git-log[]
<<generate_patch_text_with_p, "Generating patch text with -p">>).
@@ -34,9 +34,8 @@ ifdef::git-diff[]
endif::git-diff[]
-s::
---no-patch::
Suppress diff output. Useful for commands like `git show` that
- show the patch by default, or to cancel the effect of `--patch`.
+ show output by default.
endif::git-format-patch[]
ifdef::git-log[]
@@ -5493,9 +5493,12 @@ struct option *add_diff_options(const struct option *opts,
OPT_BITOP('p', "patch", &options->output_format,
N_("generate patch"),
DIFF_FORMAT_PATCH, DIFF_FORMAT_DEFAULT | DIFF_FORMAT_NO_OUTPUT),
- OPT_SET_INT_F('s', "no-patch", &options->output_format,
+ OPT_SET_INT_F('s', NULL, &options->output_format,
N_("suppress diff output"),
DIFF_FORMAT_NO_OUTPUT, PARSE_OPT_NONEG),
+ OPT_BITOP(0, "no-patch", &options->output_format,
+ N_("negate --patch"),
+ DIFF_FORMAT_NO_OUTPUT, DIFF_FORMAT_PATCH | DIFF_FORMAT_DEFAULT),
OPT_BITOP('u', NULL, &options->output_format,
N_("generate patch"),
DIFF_FORMAT_PATCH, DIFF_FORMAT_DEFAULT | DIFF_FORMAT_NO_OUTPUT),
@@ -67,9 +67,10 @@ test_expect_success 'git diff-files -s after editing work tree' '
test_must_be_empty err
'
-test_expect_success 'git diff-files --no-patch as synonym for -s' '
- git diff-files --no-patch >actual 2>err &&
- test_must_be_empty actual &&
+test_expect_success 'git diff-files --no-patch negates --patch' '
+ git diff-files >expected_raw &&
+ git diff-files --raw --patch --no-patch >actual 2>err &&
+ test_cmp expected_raw actual &&
test_must_be_empty err
'
It should silence only the --patch output, not all output. When --no-patch was introduced in d09cd15d19 (diff: allow --no-patch as synonym for -s, 2013-07-16), the idea was to have a more accessible shortcut to silence the output of `git show`. However, the interaction with other options was not considered, for example `--raw --no-patch`. The original intention remains, as `git show --no-patch` still produces the same: no output. Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com> --- Documentation/diff-options.txt | 5 ++--- diff.c | 5 ++++- t/t4000-diff-format.sh | 7 ++++--- 3 files changed, 10 insertions(+), 7 deletions(-)