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 0/7] diff: fix -s and --no-patch
Date: Fri, 12 May 2023 02:03:32 -0600 [thread overview]
Message-ID: <20230512080339.2186324-1-felipe.contreras@gmail.com> (raw)
The diff code assumes 0 means the default, and --no-patch means
NO_OUTPUT.
The problem with this approach is that it doesn't allow distinguishing
`git diff --no-patch`, `git diff --patch --no-patch`, and `git diff`.
By introducing a DIFF_FORMAT_DEFAULT (which is not 0) it's now possible
to properly distinguish these arguments, and get rid of
DIFF_FORMAT_NO_OUTPUT which should have never been considered a format,
but the absence of a format.
This fixes an issue Sergey Organov reported.
Up to patch #2 (diff: introduce DIFF_FORMAT_DEFAULT) there are no
functional changes, patch #3 (diff: make DIFF_FORMAT_NO_OUTPUT 0)
achieves the same as a series from Junio Hamano [1] except more
properly. Patch #4 adds a simplified version of Junio's test cases.
Then in patch #5 --no-patch is split from -s, making it work as
intended: negates --patch, but not other formats.
The rest are some niceties.
Now all these work correctly:
1. git diff --raw
2. git diff -s --raw
3. git diff --no-patch
4. git diff --no-patch --raw
5. git diff --patch --no-patch --raw
6. git diff --raw --patch --no-patch
[1] https://lore.kernel.org/git/20230505165952.335256-1-gitster@pobox.com/
Felipe Contreras (7):
line-log: set patch format explicitly by default
diff: introduce DIFF_FORMAT_DEFAULT
diff: make DIFF_FORMAT_NO_OUTPUT 0
test: add various tests for diff formats with -s
diff: split --no-patch from -s
diff: add --silent as alias of -s
diff: remove DIFF_FORMAT_NO_OUTPUT
Documentation/diff-options.txt | 6 ++--
blame.c | 6 ++--
builtin/diff-files.c | 2 +-
builtin/diff-index.c | 2 +-
builtin/diff-tree.c | 2 +-
builtin/diff.c | 2 +-
builtin/log.c | 16 +++++++---
builtin/stash.c | 4 +--
builtin/submodule--helper.c | 2 +-
combine-diff.c | 10 +++---
diff-merges.c | 2 +-
diff-no-index.c | 2 +-
diff.c | 56 ++++++++++++++++++----------------
diff.h | 6 +---
line-log.c | 2 +-
log-tree.c | 4 +--
merge-ort.c | 4 +--
merge-recursive.c | 4 +--
notes-merge.c | 4 +--
range-diff.c | 4 +--
revision.c | 6 ++--
t/t4000-diff-format.sh | 26 ++++++++++++++--
tree-diff.c | 2 +-
23 files changed, 99 insertions(+), 75 deletions(-)
--
2.40.0+fc1
next 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 Felipe Contreras [this message]
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 ` [PATCH v1 5/7] diff: split --no-patch from -s Felipe Contreras
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-1-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).