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

[PATCH] grep -P: add tests for matching ^ and $

From
Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Date
Feb 27, 2012, 16:45 UTC
Message-ID
<1330361149-26741-1-git-send-email-zbyszek@in.waw.pl>
In-Reply-To
<7vlinpdxsu.fsf@alter.siamese.dyndns.org>
From: Michał Kiedrowicz <michal.kiedrowicz@gmail.com>

When a fix for matching ^ and $ with -P was commited to master in fba4f1 (grep -P: Fix matching ^ and $), the tests were missing the LIBPCRE prerequisite check and were dropped from the patch. Here are the tests guarded with LIBPCRE.

Signed-off-by: Michał Kiedrowicz <michal.kiedrowicz@gmail.com>
Signed-off-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
---
 t/t7810-grep.sh |   23 +++++++++++++++++++++++
 1 file changed, 23 insertions(+)
diff --git a/t/t7810-grep.sh b/t/t7810-grep.sh
index 75f4716..d9ad633 100755
--- a/t/t7810-grep.sh
+++ b/t/t7810-grep.sh
@@ -47,6 +47,13 @@ test_expect_success setup '
 	echo vvv >t/v &&
 	mkdir t/a &&
 	echo vvv >t/a/v &&
+	{
+		echo "line without leading space1"
+		echo " line with leading space1"
+		echo " line with leading space2"
+		echo " line with leading space3"
+		echo "line without leading space2"
+	} >space &&
 	git add . &&
 	test_tick &&
 	git commit -m initial
@@ -893,4 +900,20 @@ test_expect_success 'mimic ack-grep --group' '
 	test_cmp expected actual
 '
 
+cat >expected <<EOF
+space: line with leading space1
+space: line with leading space2
+space: line with leading space3
+EOF
+
+test_expect_success LIBPCRE 'grep -E "^ "' '
+	git grep -E "^ " space >actual &&
+	test_cmp expected actual
+'
+
+test_expect_success LIBPCRE 'grep -P "^ "' '
+	git grep -P "^ " space >actual &&
+	test_cmp expected actual
+'
+
 test_done
-- 
1.7.9.2.396.ga883d.dirty
Previous: Junio C HamanoNext: Junio C Hamano
Message 5 of 6 in “grep -P: Fix matching ^ and $”
  1. grep -P: Fix matching ^ and $Michał Kiedrowicz, Feb 25, 2012
  2. Michał KiedrowiczFeb 25, 2012
  3. Zbigniew Jędrzejewski-SzmekFeb 25, 2012
  4. Junio C HamanoFeb 26, 2012
  5. grep -P: add tests for matching ^ and $Zbigniew Jędrzejewski-Szmek, Feb 27, 2012
  6. Junio C HamanoFeb 27, 2012

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.