git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH maint 2/2] t4018-diff-funcname: demonstrate end of line funcname matching flaw

From
drafnel@gmail.com <drafnel@gmail.com>
Date
Oct 16, 2008, 00:58 UTC
Message-ID
<6078773.1224118690194.JavaMail.teamon@b307.teamon.com>
In-Reply-To
<1224118730-24711-1-git-send-email-drafnel@gmail.com>

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>
---
 t/t4018-diff-funcname.sh |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/t/t4018-diff-funcname.sh b/t/t4018-diff-funcname.sh
index 72076ec..40a805a 100755
--- a/t/t4018-diff-funcname.sh
+++ b/t/t4018-diff-funcname.sh
@@ -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 |
-- 
1.6.0.2.101.gb844
Previous: Junio C Hamano
Message 16 of 16 in “What's in git.git (Oct 2008, #03; Tue, 14)”
  1. Junio C HamanoOct 14, 2008
  2. Brandon CaseyOct 15, 2008
  3. Mike RalphsonOct 15, 2008
  4. Junio C HamanoOct 15, 2008
  5. Shawn O. PearceOct 15, 2008
  6. Junio C HamanoOct 15, 2008
  7. Shawn O. PearceOct 15, 2008
  8. 1/2 t4018-diff-funcname: rework negated last expression testdrafnel@gmail.com, Oct 16, 2008
  9. Jeff KingOct 16, 2008
  10. Brandon CaseyOct 16, 2008
  11. Pieter de BieOct 16, 2008
  12. Arjen LaarhovenOct 17, 2008
  13. Junio C HamanoOct 24, 2008
  14. Jeff KingOct 17, 2008
  15. Junio C HamanoOct 17, 2008
  16. 2/2 t4018-diff-funcname: demonstrate end of line funcname matching flawdrafnel@gmail.com, Oct 16, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.