summaryrefslogtreecommitdiff
path: root/diff.c
diff options
context:
space:
mode:
authorLibravatar Junio C Hamano <gitster@pobox.com>2020-12-16 17:27:13 -0800
committerLibravatar Junio C Hamano <gitster@pobox.com>2020-12-16 17:33:26 -0800
commit50f04394908fe308a421b360951b1f73b00363ee (patch)
treed337ef464efc41b9a293bbf5b6e617f81dc9b14e /diff.c
parentdiff: add -I<regex> that ignores matching changes (diff)
downloadtgif-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 'diff.c')
-rw-r--r--diff.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/diff.c b/diff.c
index 92e247fb83..e162d59eae 100644
--- a/diff.c
+++ b/diff.c
@@ -4602,7 +4602,8 @@ void diff_setup_done(struct diff_options *options)
* inside contents.
*/
- if ((options->xdl_opts & XDF_WHITESPACE_FLAGS))
+ if ((options->xdl_opts & XDF_WHITESPACE_FLAGS) ||
+ options->ignore_regex_nr)
options->flags.diff_from_contents = 1;
else
options->flags.diff_from_contents = 0;