diff: teach "--stat -w --exit-code" to notice differences
commite8efd863699c6927953ebff6cb317c5632b7324d
authorJunio C Hamano <gitster@pobox.com>
Fri, 18 Aug 2023 23:59:30 +0000 (18 16:59 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sat, 19 Aug 2023 00:01:11 +0000 (18 17:01 -0700)
tree3b1e53f8bc91926591072c5055757b5746269fb7
parentc9a3e724cf75b44e47cfca5ae37cd0d7864c2220
diff: teach "--stat -w --exit-code" to notice differences

When options like "-w" is used while "--exit-code" option is in
effect, instead of the usual "do we have any filepair whose preimage
and postimage have different <mode,object>?" check, we need to compare
the contents of the blobs, taking into account that certain changes
are considered no-op.

With the previous step, we taught "--patch" codepath to set the
.found_changes bit correctly, even for a change that only affects
the mode and not object.  The "--stat" codepath, however, did not
set the .found_changes bit at all.  This lead to

    $ git diff --stat -w --exit-code

for a change that does have an output to exit with status 0.

Set the bit by inspecting the list of paths the diffstat output is
given for (a mode-only change will still appear as a "0-line added
0-line deleted" change) to fix it.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff.c
t/t4015-diff-whitespace.sh