From: Felipe Contreras <felipe.contreras@gmail.com>
To: git@vger.kernel.org
Cc: Sergey Organov <sorganov@gmail.com>,
Junio C Hamano <gitster@pobox.com>,
Felipe Contreras <felipe.contreras@gmail.com>
Subject: [PATCH v1 5/7] diff: split --no-patch from -s
Date: Fri, 12 May 2023 02:03:37 -0600 [thread overview]
Message-ID: <20230512080339.2186324-6-felipe.contreras@gmail.com> (raw)
In-Reply-To: <20230512080339.2186324-1-felipe.contreras@gmail.com>
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(-)
diff --git a/Documentation/diff-options.txt b/Documentation/diff-options.txt
index 08ab86189a..ba04b8292a 100644
--- a/Documentation/diff-options.txt
+++ b/Documentation/diff-options.txt
@@ -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[]
diff --git a/diff.c b/diff.c
index 4f4b1d7e13..45c860496f 100644
--- a/diff.c
+++ b/diff.c
@@ -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),
diff --git a/t/t4000-diff-format.sh b/t/t4000-diff-format.sh
index 7829cc810d..d7b9a2dab8 100755
--- a/t/t4000-diff-format.sh
+++ b/t/t4000-diff-format.sh
@@ -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
'
--
2.40.0+fc1
next prev parent reply other threads:[~2023-05-12 8:03 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-12 8:03 [PATCH v1 0/7] diff: fix -s and --no-patch Felipe Contreras
2023-05-12 8:03 ` [PATCH v1 1/7] line-log: set patch format explicitly by default Felipe Contreras
2023-05-12 8:03 ` [PATCH v1 2/7] diff: introduce DIFF_FORMAT_DEFAULT Felipe Contreras
2023-05-12 8:03 ` [PATCH v1 3/7] diff: make DIFF_FORMAT_NO_OUTPUT 0 Felipe Contreras
2023-05-12 8:03 ` [PATCH v1 4/7] test: add various tests for diff formats with -s Felipe Contreras
2023-05-12 8:03 ` Felipe Contreras [this message]
2023-05-12 8:03 ` [PATCH v1 6/7] diff: add --silent as alias of -s Felipe Contreras
2023-05-12 8:03 ` [PATCH v1 7/7] diff: remove DIFF_FORMAT_NO_OUTPUT Felipe Contreras
2023-05-12 8:20 ` [PATCH v1 0/7] diff: fix -s and --no-patch Felipe Contreras
2023-05-12 9:32 ` Sergey Organov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230512080339.2186324-6-felipe.contreras@gmail.com \
--to=felipe.contreras@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=sorganov@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).