diff options
author | Junio C Hamano <gitster@pobox.com> | 2020-12-16 17:27:13 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2020-12-16 17:33:26 -0800 |
commit | 50f04394908fe308a421b360951b1f73b00363ee (patch) | |
tree | d337ef464efc41b9a293bbf5b6e617f81dc9b14e /t | |
parent | diff: add -I<regex> that ignores matching changes (diff) | |
download | tgif-50f04394908fe308a421b360951b1f73b00363ee.tar.xz |
diff: correct interaction between --exit-code and -I<pattern>
Just like "git diff -w --exit-code" should exit with 0 when ignoring
whitespace differences results in no changes shown, if ignoring
certain changes with "git diff -I<pattern> --exit-code" result in an
empty patch, we should exit with 0.
The test suite did not cover the interaction between "--exit-code"
and "-w"; add one while adding a new test for "--exit-code" + "-I".
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-x | t/t4015-diff-whitespace.sh | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/t/t4015-diff-whitespace.sh b/t/t4015-diff-whitespace.sh index 88d3026894..8ae02fe3c3 100755 --- a/t/t4015-diff-whitespace.sh +++ b/t/t4015-diff-whitespace.sh @@ -567,6 +567,30 @@ test_expect_success '--check and --quiet are not exclusive' ' git diff --check --quiet ' +test_expect_success '-w and --exit-code interact sensibly' ' + test_when_finished "git checkout x" && + { + test_seq 15 && + echo " 16" + } >x && + test_must_fail git diff --exit-code && + git diff -w >actual && + test_must_be_empty actual && + git diff -w --exit-code +' + +test_expect_success '-I and --exit-code interact sensibly' ' + test_when_finished "git checkout x" && + { + test_seq 15 && + echo " 16" + } >x && + test_must_fail git diff --exit-code && + git diff -I. >actual && + test_must_be_empty actual && + git diff -I. --exit-code +' + test_expect_success 'check staged with no whitespace errors' ' echo "foo();" >x && git add x && |