git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[RFC PATCH 0/4] diff: fix default/no-output

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
May 9, 2023, 00:44 UTC
Message-ID
<20230509004406.1786033-1-felipe.contreras@gmail.com>

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 of a format, but the absense of the DIFF_FORMAT_PATCH format.

This fixes an issue Sergey Organov reported.
Now all these 3 work correctly:
 1. git diff --raw
 2. git diff --patch --no-patch --raw
 3. git diff --raw --patch --no-patch
Felipe Contreras (3):
  line-log: set patch format explicitly by default
  diff: introduce DIFF_FORMAT_DEFAULT
  diff: remove DIFF_FORMAT_NO_OUTPUT
Sergey Organov (1):
  t4013: add expected failure for "log --patch --no-patch"
 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                      | 53 ++++++++++++++++++-------------------
 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/t4013-diff-various.sh     |  8 ++++++
 tree-diff.c                 |  2 +-
 22 files changed, 78 insertions(+), 69 deletions(-)
-- 
2.40.0+fc1
Next: Felipe Contreras
Message 1 of 5 in “diff: fix default/no-output”
  1. 0/4 diff: fix default/no-outputFelipe Contreras, May 9, 2023
  2. 1/4 t4013: add expected failure for "log --patch --no-patch"Felipe Contreras, May 9, 2023
  3. 2/4 line-log: set patch format explicitly by defaultFelipe Contreras, May 9, 2023
  4. 3/4 diff: introduce DIFF_FORMAT_DEFAULTFelipe Contreras, May 9, 2023
  5. 4/4 diff: remove DIFF_FORMAT_NO_OUTPUTFelipe Contreras, May 9, 2023

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.