summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: e701fad)
raw | patch | inline | side by side (parent: e701fad)
author | René Scharfe <rene.scharfe@lsrfire.ath.cx> | |
Sat, 23 May 2009 11:45:26 +0000 (13:45 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sat, 23 May 2009 23:29:05 +0000 (16:29 -0700) |
After bol is forwarded, it doesn't represent the beginning of the line
any more. This means that the beginning-of-line marker (^) mustn't match,
i.e. the regex flag REG_NOTBOL needs to be set.
This bug was introduced by fb62eb7fab97cea880ea7fe4f341a4dfad14ab48
("grep -w: forward to next possible position after rejected match").
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
any more. This means that the beginning-of-line marker (^) mustn't match,
i.e. the regex flag REG_NOTBOL needs to be set.
This bug was introduced by fb62eb7fab97cea880ea7fe4f341a4dfad14ab48
("grep -w: forward to next possible position after rejected match").
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
grep.c | patch | blob | history | |
t/t7002-grep.sh | patch | blob | history |
index a649f063cf28baa5b0ddce72d7d6e4d9fca6f360..cc6d5b04c15b670c55bdb9e2089e0b71f72453cc 100644 (file)
--- a/grep.c
+++ b/grep.c
bol = pmatch[0].rm_so + bol + 1;
while (word_char(bol[-1]) && bol < eol)
bol++;
+ eflags |= REG_NOTBOL;
if (bol < eol)
goto again;
}
diff --git a/t/t7002-grep.sh b/t/t7002-grep.sh
index b81593780a2a6adaf34bb10293b607e3a303cfcd..f275af82403dc0f1de4c584074c0eb63e61a6704 100755 (executable)
--- a/t/t7002-grep.sh
+++ b/t/t7002-grep.sh
echo foo mmap bar_mmap
echo foo_mmap bar mmap baz
} >file &&
+ echo ww w >w &&
echo x x xx x >x &&
echo y yy >y &&
echo zzz > z &&
mkdir t &&
echo test >t/t &&
- git add file x y z t/t &&
+ git add file w x y z t/t &&
test_tick &&
git commit -m initial
'
diff expected actual
'
+ test_expect_success "grep -w $L (w)" '
+ : >expected &&
+ ! git grep -n -w -e "^w" >actual &&
+ test_cmp expected actual
+ '
+
test_expect_success "grep -w $L (x)" '
{
echo ${HC}x:1:x x xx x