Skip to content

Commit 59fcf74

Browse files
committed
Merge branch 'jc/diff-I-status-fix'
"git diff -I<pattern> -exit-code" should exit with 0 status when all the changes match the ignored pattern, but it didn't. * jc/diff-I-status-fix: diff: correct interaction between --exit-code and -I<pattern>
2 parents d4187bd + 50f0439 commit 59fcf74

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

diff.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4634,7 +4634,8 @@ void diff_setup_done(struct diff_options *options)
46344634
* inside contents.
46354635
*/
46364636

4637-
if ((options->xdl_opts & XDF_WHITESPACE_FLAGS))
4637+
if ((options->xdl_opts & XDF_WHITESPACE_FLAGS) ||
4638+
options->ignore_regex_nr)
46384639
options->flags.diff_from_contents = 1;
46394640
else
46404641
options->flags.diff_from_contents = 0;

t/t4015-diff-whitespace.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,30 @@ test_expect_success '--check and --quiet are not exclusive' '
567567
git diff --check --quiet
568568
'
569569

570+
test_expect_success '-w and --exit-code interact sensibly' '
571+
test_when_finished "git checkout x" &&
572+
{
573+
test_seq 15 &&
574+
echo " 16"
575+
} >x &&
576+
test_must_fail git diff --exit-code &&
577+
git diff -w >actual &&
578+
test_must_be_empty actual &&
579+
git diff -w --exit-code
580+
'
581+
582+
test_expect_success '-I and --exit-code interact sensibly' '
583+
test_when_finished "git checkout x" &&
584+
{
585+
test_seq 15 &&
586+
echo " 16"
587+
} >x &&
588+
test_must_fail git diff --exit-code &&
589+
git diff -I. >actual &&
590+
test_must_be_empty actual &&
591+
git diff -I. --exit-code
592+
'
593+
570594
test_expect_success 'check staged with no whitespace errors' '
571595
echo "foo();" >x &&
572596
git add x &&

0 commit comments

Comments
 (0)