]> git.ipfire.org Git - thirdparty/git.git/commit
diff: report copies and renames as changes in run_diff_cmd()
authorRené Scharfe <l.s.r@web.de>
Sun, 8 Sep 2024 07:05:44 +0000 (09:05 +0200)
committerJunio C Hamano <gitster@pobox.com>
Sun, 8 Sep 2024 20:21:23 +0000 (13:21 -0700)
commit87cf96094a6b5ccc4a9a1d92b9958ad0869a5c90
treea62d27300f27c78482d9a6dc039982e61f06d74c
parent39bf06adf96da25b87c9aa7d35a32ef3683eb4a4
diff: report copies and renames as changes in run_diff_cmd()

The diff machinery has two ways to detect changes to set the exit code:
Just comparing hashes and comparing blob contents.  The latter is needed
if certain changes have to be ignored, e.g. with --ignore-space-change
or --ignore-matching-lines.  It's enabled by the diff_options flag
diff_from_contents.

The slower mode has never considered copies and renames to be changes,
which is inconsistent with the quicker one.  Fix it.  Even if we ignore
the file contents (because it's empty or contains only ignored lines),
there's still the meta data change of adding or changing a filename, so
we need to report it in the exit code.

d7b97b7185 (diff: let external diffs report that changes are
uninteresting, 2024-06-09) set diff_from_contents if external diff
programs are allowed.  This is the default e.g. for git diff, and so
that change exposed the inconsistency much more widely.

Reported-by: Jorge Luis Martinez Gomez <jol@jol.dev>
Signed-off-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff.c
t/t4017-diff-retval.sh