Skip to content

Commit b19d288

Browse files
drafnelgitster
authored andcommitted
t4018-diff-funcname: demonstrate end of line funcname matching flaw
Since the newline is not removed from lines before pattern matching, a pattern cannot match to the end of the line using the '$' operator without using an additional operator which will indirectly match the '\n' character. Introduce a test which should pass, but which does not due to this flaw. Signed-off-by: Brandon Casey <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 16b2672 commit b19d288

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

t/t4018-diff-funcname.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ test_expect_success 'last regexp must not be negated' '
6969
grep "fatal: Last expression must not be negated:"
7070
'
7171

72+
test_expect_failure 'pattern which matches to end of line' '
73+
git config diff.java.funcname "Beer$" &&
74+
git diff --no-index Beer.java Beer-correct.java |
75+
grep "^@@.*@@ Beer"
76+
'
77+
7278
test_expect_success 'alternation in pattern' '
7379
git config diff.java.xfuncname "^[ ]*((public|static).*)$" &&
7480
git diff --no-index Beer.java Beer-correct.java |

0 commit comments

Comments
 (0)