git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Rast <trast@inf.ethz.ch>
To: Junio C Hamano <gitster@pobox.com>
Cc: <git@vger.kernel.org>
Subject: Re: [PATCH 2/4] t4011: illustrate "diff-index -p" on stat-dirty paths
Date: Thu, 1 Mar 2012 10:05:59 +0100	[thread overview]
Message-ID: <87399slmh4.fsf@thomas.inf.ethz.ch> (raw)
In-Reply-To: <1330568057-27304-3-git-send-email-gitster@pobox.com> (Junio C. Hamano's message of "Wed, 29 Feb 2012 18:14:15 -0800")

Junio C Hamano <gitster@pobox.com> writes:

> The plumbing that looks at the working tree, i.e. "diff-index" and
> "diff-files", always emit the "diff --git a/path b/path" header lines
> without anything else for paths that are only stat-dirty (i.e. different
> only because the cached stat information in the index no longer matches
> that of the working tree, but the real contents are the same), when
> these commands are run with "-p" option to produce patches.
>
> Illustrate this current behaviour.  The new part that uses "-w" option
> demonstrates that we do not show any "diff --git" header for blobs whose
> true contents are different but compares the same when whitespaces are
> ignored, which is inconsistent with the behaviour for stat-dirty paths.
[...]
> -test_expect_success SYMLINKS 'diff identical, but newly created symlink' '
> +test_expect_success SYMLINKS 'diff identical, but newly created symlink and file' '
>  	cat >expected <<-\EOF &&
>  	diff --git a/frotz b/frotz
> +	diff --git a/nitfol b/nitfol
>  	EOF
> +	sleep 3 &&
> +	rm -f frotz &&
> +	echo xyzzy >nitfol3 &&
> +	mv nitfol3 nitfol &&
>  	ln -s xyzzy frotz &&
>  	git diff-index -M -p $tree >current &&
> +	compare_diff_patch expected current &&
> +
> +	>expected &&
> +	git diff-index -M -p -w $tree >current &&
>  	compare_diff_patch expected current
>  '

I find the last bit of the commit message rather confusing.  You appear
to be using -w here to diff the stat-dirty worktree nitfol 'xyzzy\n'
against the $tree:nitfol which is also 'xyzzy\n'.

If that analysis is correct, then

  we do not show any "diff --git" header for blobs whose true contents
  are different but compares the same when whitespaces are ignored

is not what is going on here; the blobs have exactly the same content.
The difference is that

* without -w, the code "knows" from the lstat() data that the files are
  different, prints a header, and then fails to find any differences;

* with -w, the code correctly holds off on printing anything since it
  will invariably have to inspect the contents beforehand.

So perhaps you can say

  Illustrate this current behaviour.  Also demonstrate that with the
  "-w" option, we (correctly) hold off showing a "diff --git" header
  until actual differences have been found.  This also suppresses the
  header for merely stat-dirty files, which is inconsistent.

-- 
Thomas Rast
trast@{inf,student}.ethz.ch

  reply	other threads:[~2012-03-01  9:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-03-01  2:14 [PATCH 0/4] "diff -p" patch header generation updates Junio C Hamano
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 [this message]
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=87399slmh4.fsf@thomas.inf.ethz.ch \
    --to=trast@inf.ethz.ch \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.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 NNTP newsgroup(s).