Skip to content

Commit

Permalink
t4018-diff-funcname: demonstrate end of line funcname matching flaw
Browse files Browse the repository at this point in the history
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 <drafnel@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
drafnel authored and gitster committed Oct 16, 2008
1 parent 16b2672 commit b19d288
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions t/t4018-diff-funcname.sh
Expand Up @@ -69,6 +69,12 @@ test_expect_success 'last regexp must not be negated' '
grep "fatal: Last expression must not be negated:"
'

test_expect_failure 'pattern which matches to end of line' '
git config diff.java.funcname "Beer$" &&
git diff --no-index Beer.java Beer-correct.java |
grep "^@@.*@@ Beer"
'

test_expect_success 'alternation in pattern' '
git config diff.java.xfuncname "^[ ]*((public|static).*)$" &&
git diff --no-index Beer.java Beer-correct.java |
Expand Down

0 comments on commit b19d288

Please sign in to comment.