summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2024-05-05 12:19:56 +0200
committerJunio C Hamano <gitster@pobox.com>2024-05-06 10:23:40 -0700
commit7b30c3ad2da76bde9f49b049890acac0943d4c76 (patch)
tree4ed08f1822d079e8c3759f6c0978ec4b8d614b61 /diff.c
parent3c2a3fdc388747b9eaf4a4a4f2035c1c9ddb26d0 (diff)
diff: report unmerged paths as changes in run_diff_cmd()
You can ask the diff machinery to let the exit code indicate whether there are changes, e.g. with --quiet. It as two ways to calculate that bit: The quick one assumes blobs with different hashes have different content, and the more elaborate way actually compares the contents, possibly applying transformations like ignoring whitespace. The quick way considers an unmerged file to be a change and reports exit code 1, which makes sense. The slower path uses the struct diff_options member found_changes to indicate whether the blobs differ even with the transformations applied. It's not set for unmerged files, though, resulting in exit code 0. Set found_changes in run_diff_cmd() for unmerged files, for a consistent exit code of 1 if there's an unmerged file, regardless of whether whitespace is ignored. Signed-off-by: René Scharfe <l.s.r@web.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'diff.c')
-rw-r--r--diff.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/diff.c b/diff.c
index e50def4538..38773317a1 100644
--- a/diff.c
+++ b/diff.c
@@ -4547,6 +4547,7 @@ static void run_diff_cmd(const char *pgm,
o, complete_rewrite);
} else {
fprintf(o->file, "* Unmerged path %s\n", name);
+ o->found_changes = 1;
}
}