diff: change semantics of "ignore whitespace" options
commitf245194f9a13d5108c3a59fd4ab1770ae9fd5b65
authorJunio C Hamano <gitster@pobox.com>
Fri, 22 May 2009 19:45:29 +0000 (22 12:45 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 29 Jul 2009 17:22:39 +0000 (29 10:22 -0700)
tree54cb9801bccbe837970f2fc0993f45710dae0b40
parent0a53e9ddeaddad63ad106860237bbf53411d11a7
diff: change semantics of "ignore whitespace" options

Traditionally, the --ignore-whitespace* options have merely meant to tell
the diff output routine that some class of differences are not worth
showing in the textual diff output, so that the end user has easier time
to review the remaining (presumably more meaningful) changes.  These
options never affected the outcome of the command, given as the exit
status when the --exit-code option was in effect (either directly or
indirectly).

When you have only whitespace changes, however, you might expect

git diff -b --exit-code

to report that there is _no_ change with zero exit status.

Change the semantics of --ignore-whitespace* options to mean more than
"omit showing the difference in text".

The exit status, when --exit-code is in effect, is computed by checking if
we found any differences at the path level, while diff frontends feed
filepairs to the diffcore engine.  When "ignore whitespace" options are in
effect, we defer this determination until the very end of diffcore
transformation.  We simply do not know until the textual diff is
generated, which comes very late in the pipeline.

When --quiet is in effect, various diff frontends optimize by breaking out
early from the loop that enumerates the filepairs, when we find the first
path level difference; when --ignore-whitespace* is used the above change
automatically disables this optimization.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff.c
diff.h
t/t4037-whitespace-status.sh [new file with mode: 0755]
tree-diff.c