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

[PATCH 0/4] "diff -p" patch header generation updates

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 1, 2012, 02:14 UTC
Message-ID
<1330568057-27304-1-git-send-email-gitster@pobox.com>

There has always been one thing fishy about the plumbing level "diff" used to generate patches with "-p" option: we produced a header-only diff when there is no patch necessary to be shown, when there is no contents change. We are calling into xdiff to produce a patch, and we should have all the necessary information to suppress the unnecessary header, but because historically we didn't, we never updated the code to do so.

It turns out that we already have the necessary machinery to notice such a situation and suppressing the useless header. We just did not realize that we could use it. There is a backward compatibility worry for scripts, but I would imagine that the scripts saw these header-only diff as a nuisance that needs to be filtered out, not a feature to learn about paths that are only stat-dirty. And more importantly, even if this _were_ a feature, it was not working correctly when "-w" option was in effect to begin with, as the second one in the series illustrates.

This series changes the world order that is almost 6 years old. No more phantom diff headers in patch output due to stat-dirtiness.

The first patch in this series replaces the one I posted earlier (one block that prepares the expected result was in a wrong test).

The second patch adds test vectors that illustrate the current behaviour that will be changed with this series.

The third patch is the real change, whose effect can be seen in the patch to the test the second one introduces.

The fourth one is unrelated from the rest of the series from the feature point of view, but its implementation depends on the updated semantics of header suppression.

The series is designed to apply on top of v1.7.4-rc0~147 and has trivial conflict in diff.h if applied/merged to 'master'. Just take the addition of DIFF_OPT* macros from both sides.

Junio C Hamano (4):
  t4011: modernise style
  t4011: illustrate "diff-index -p" on stat-dirty paths
  diff -p: squelch "diff --git" header for stat-dirty paths
  diff --ignore-mode-change
 diff.c                  |   31 +++++++-
 diff.h                  |    1 +
 t/t4011-diff-symlink.sh |  196 +++++++++++++++++++++++++++--------------------
 3 files changed, 141 insertions(+), 87 deletions(-)
-- 
1.7.9.2.350.g74d65
Next: Junio C Hamano
Message 1 of 10 in “"diff -p" patch header generation updates”
  1. 0/4 "diff -p" patch header generation updatesJunio C Hamano, Mar 1, 2012
  2. 1/4 t4011: modernise styleJunio C Hamano, Mar 1, 2012
  3. 2/4 t4011: illustrate "diff-index -p" on stat-dirty pathsJunio C Hamano, Mar 1, 2012
  4. Thomas RastMar 1, 2012
  5. Junio C HamanoMar 1, 2012
  6. 2/4 t4011: illustrate "diff-index -p" on stat-dirty pathsJunio C Hamano, Mar 1, 2012
  7. Zbigniew Jędrzejewski-SzmekMar 1, 2012
  8. Junio C HamanoMar 1, 2012
  9. 3/4 diff -p: squelch "diff --git" header for stat-dirty pathsJunio C Hamano, Mar 1, 2012
  10. 4/4 diff --ignore-mode-changeJunio C Hamano, Mar 1, 2012

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.