diff: mode-only change should be noticed by "--patch -w --exit-code"
commitc9a3e724cf75b44e47cfca5ae37cd0d7864c2220
authorJunio C Hamano <gitster@pobox.com>
Fri, 18 Aug 2023 23:59:29 +0000 (18 16:59 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sat, 19 Aug 2023 00:01:11 +0000 (18 17:01 -0700)
tree6c4cd7daf7462c9ebc290aa1e4bc4e97ebe90154
parent5f107caed755dae950382fdafc76a33b31528caa
diff: mode-only change should be noticed by "--patch -w --exit-code"

The codepath to notice the content-level changes, taking certain
no-op changes like "ignore whitespace" into account, forgot that
a mode-only change is still a change.  This resulted in

    $ git diff --patch --exit-code -w

to exit with status 0 even when there is such a mode-only change,
breaking both "--patch" and "--quiet" output formats.

Teach the builtin_diff() codepath that creation and deletion as well
as mode changes are all interesting changes.

Note that the test specifically checks removal of an empty file,
because if there is anything in the preimage (i.e. the removed file
is not empty), the removal would still trigger textual patch output
and the codepath for that does update .found_changes bit to report
that it found an interesting change.  We need to make sure that the
.found_changes bit is set even without triggering textual patch
output.

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