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

Re: [PATCH 2/4] t4011: illustrate "diff-index -p" on stat-dirty paths

From
Thomas Rast <trast@inf.ethz.ch>
Date
Mar 1, 2012, 09:05 UTC
Message-ID
<87399slmh4.fsf@thomas.inf.ethz.ch>
In-Reply-To
<1330568057-27304-3-git-send-email-gitster@pobox.com>
Junio C Hamano <gitster@pobox.com> writes:
Show 11 quoted lines
> 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.
[...]
Show 18 quoted lines
> -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
Previous: Junio C HamanoNext: Junio C Hamano
Message 4 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.