aboutsummaryrefslogtreecommitdiffstats
path: root/t/t4020-diff-external.sh
diff options
context:
space:
mode:
authorRené Scharfe <l.s.r@web.de>2024-05-05 12:20:03 +0200
committerJunio C Hamano <gitster@pobox.com>2024-05-06 10:23:42 -0700
commit11be65cfa43416219e85384a3a80d672b65b76ba (patch)
tree4e2afc0ee9875b2b9810a128a81154bad9ad8306 /t/t4020-diff-external.sh
parentdiff: report unmerged paths as changes in run_diff_cmd() (diff)
downloadgit-11be65cfa43416219e85384a3a80d672b65b76ba.tar.gz
git-11be65cfa43416219e85384a3a80d672b65b76ba.zip
diff: fix --exit-code with external diff
You can ask the diff machinery to let the exit code indicate whether there are changes, e.g. with --exit-code. 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. Always use the slower path by setting the flag diff_from_contents, because any of the files could have an external diff driver set via an attribute, which might consider binary differences irrelevant, like e.g. Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t4020-diff-external.sh')
-rwxr-xr-xt/t4020-diff-external.sh8
1 files changed, 8 insertions, 0 deletions
diff --git a/t/t4020-diff-external.sh b/t/t4020-diff-external.sh
index c1ac09ecc7..b525d16c90 100755
--- a/t/t4020-diff-external.sh
+++ b/t/t4020-diff-external.sh
@@ -172,6 +172,14 @@ test_expect_success 'no diff with -diff' '
grep Binary out
'
+test_expect_success 'diff.external and --exit-code with output' '
+ test_expect_code 1 git -c diff.external=echo diff --exit-code
+'
+
+test_expect_success 'diff.external and --exit-code without output' '
+ git -c diff.external=true diff --exit-code
+'
+
echo NULZbetweenZwords | perl -pe 'y/Z/\000/' > file
test_expect_success 'force diff with "diff"' '