Re: [PATCH v2 19/27] gitattributes doc: document multi-line userdiff patterns
flat view
From: Johannes Sixt <hidden>
Date: 2021-02-15 18:20:05
Am 15.02.21 um 16:44 schrieb Ævar Arnfjörð Bjarmason:
quoted hunk ↗ jump to hunk
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?
quoted hunk ↗ jump to hunk
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. -- Hannes