git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Subject: [PATCH 0/4] "diff -p" patch header generation updates
Date: Wed, 29 Feb 2012 18:14:13 -0800	[thread overview]
Message-ID: <1330568057-27304-1-git-send-email-gitster@pobox.com> (raw)

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

             reply	other threads:[~2012-03-01  2:14 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-01  2:14 Junio C Hamano [this message]
2012-03-01  2:14 ` [PATCH 1/4] t4011: modernise style Junio C Hamano
2012-03-01  2:14 ` [PATCH 2/4] t4011: illustrate "diff-index -p" on stat-dirty paths Junio C Hamano
2012-03-01  9:05   ` Thomas Rast
2012-03-01 16:18     ` Junio C Hamano
2012-03-01 16:52     ` [PATCH 2/4 v2] " Junio C Hamano
2012-03-01 10:05   ` [PATCH 2/4] " Zbigniew Jędrzejewski-Szmek
2012-03-01 16:10     ` Junio C Hamano
2012-03-01  2:14 ` [PATCH 3/4] diff -p: squelch "diff --git" header for " Junio C Hamano
2012-03-01  2:14 ` [PATCH 4/4] diff --ignore-mode-change Junio C Hamano

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=1330568057-27304-1-git-send-email-gitster@pobox.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    /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 NNTP newsgroup(s).