On Mon, Feb 15 2021, Johannes Sixt wrote: > Am 15.02.21 um 16:44 schrieb Ævar Arnfjörð Bjarmason: >> diff --git a/t/t4018/custom.sh b/t/t4018/custom.sh >> index 72d38dad68..30df13d8b2 100755 >> --- a/t/t4018/custom.sh >> +++ b/t/t4018/custom.sh >> @@ -111,3 +111,53 @@ ChangeMe >> baz >> EOF_TEST >> + >> +test_expect_success 'custom: setup negation syntax, ! is magic' ' >> + git config diff.custom.xfuncname "!negation >> +line" >> +' >> + >> +test_diff_funcname 'custom: negation syntax, ! is magic' \ >> + 8<<\EOF_HUNK 9<<\EOF_TEST >> +line >> +EOF_HUNK >> +line >> +!negation >> + >> +ChangeMe >> + >> +baz >> +EOF_TEST >> + >> +test_expect_success 'custom: setup negation syntax, use [!] to override ! magic' ' >> + git config diff.custom.xfuncname "[!]negation >> +line" >> +' >> + >> +test_diff_funcname 'custom: negation syntax, use [!] to override ! magic' \ >> + 8<<\EOF_HUNK 9<<\EOF_TEST >> +!negation >> +EOF_HUNK >> +line >> +!negation >> + >> +ChangeMe >> + >> +baz >> +EOF_TEST >> + >> +test_expect_success 'custom: setup captures in multiple patterns' ' >> + git config diff.custom.xfuncname "!^=head >> +^format ([^ ]+) >> +^sub ([^;]+)" >> +' >> + >> +test_diff_funcname 'custom: captures in multiple patterns' \ >> + 8<<\EOF_HUNK 9<<\EOF_TEST >> +foo >> +EOF_HUNK >> +sub foo; >> +=head1 >> +ChangeMe >> + >> +EOF_TEST > > This test would not catch a regression. You must leave a line between > the candidate-that-must-not-be, =head1, and ChangeMe, otherwise, > =head1 is never tested against the negation pattern. > > Or did you change the diff invocation in an earlier patch such that it > does not emit context lines? > >> diff --git a/t/t4018/perl.sh b/t/t4018/perl.sh >> index ac8fff7417..2952483a2c 100755 >> --- a/t/t4018/perl.sh >> +++ b/t/t4018/perl.sh >> @@ -76,3 +76,19 @@ sub RIGHT >> print "ChangeMe\n"; >> } >> EOF_TEST >> + >> + >> +test_expect_success 'custom: setup config overrides built-in patterns' ' >> + git config diff.perl.xfuncname "!^=head >> +^[^ ]+.*" >> +' >> + >> +test_diff_funcname 'custom: config overrides built-in patterns' \ >> + 8<<\EOF_HUNK 9<<\EOF_TEST >> +sub foo; >> +EOF_HUNK >> +sub foo; >> +=head1 >> +ChangeMe >> + >> +EOF_TEST > > Same here. Well spotted. Both of these test work for their advertised purpose. I.e. "we can override the perl built-in config" and "capture count gets reset", but you're right that the =head1 negation rule is redundant at this point in the series. In 23/27 we start testing with -U0, at which point it starts working. But of course a better fix is to just add an empty line here...