Skip to content

Commit d29d787

Browse files
mkiedrowiczgitster
authored andcommitted
grep -P: add tests for matching ^ and $
Earlier, fba4f1 (grep -P: Fix matching ^ and $) fixed an ancient bug. Add some tests to protect the change from future breakages; a slightly broken version of this was a part of the originally submitted patch. Signed-off-by: Michał Kiedrowicz <[email protected]> Signed-off-by: Zbigniew Jędrzejewski-Szmek <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3ddf922 commit d29d787

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

t/t7810-grep.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,13 @@ test_expect_success setup '
4747
echo vvv >t/v &&
4848
mkdir t/a &&
4949
echo vvv >t/a/v &&
50+
{
51+
echo "line without leading space1"
52+
echo " line with leading space1"
53+
echo " line with leading space2"
54+
echo " line with leading space3"
55+
echo "line without leading space2"
56+
} >space &&
5057
git add . &&
5158
test_tick &&
5259
git commit -m initial
@@ -893,4 +900,20 @@ test_expect_success 'mimic ack-grep --group' '
893900
test_cmp expected actual
894901
'
895902

903+
cat >expected <<EOF
904+
space: line with leading space1
905+
space: line with leading space2
906+
space: line with leading space3
907+
EOF
908+
909+
test_expect_success LIBPCRE 'grep -E "^ "' '
910+
git grep -E "^ " space >actual &&
911+
test_cmp expected actual
912+
'
913+
914+
test_expect_success LIBPCRE 'grep -P "^ "' '
915+
git grep -P "^ " space >actual &&
916+
test_cmp expected actual
917+
'
918+
896919
test_done

0 commit comments

Comments
 (0)