Skip to content

Commit

Permalink
Merge branch 'rs/maint-grep-word-regexp-fix'
Browse files Browse the repository at this point in the history
* rs/maint-grep-word-regexp-fix:
  grep: fix word-regexp at the beginning of lines
  • Loading branch information
Junio C Hamano committed May 29, 2009
2 parents 3be7e06 + dbb6a4a commit 8e105e3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions grep.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ static int match_one_pattern(struct grep_pat *p, char *bol, char *eol,
bol = pmatch[0].rm_so + bol + 1;
while (word_char(bol[-1]) && bol < eol)
bol++;
eflags |= REG_NOTBOL;
if (bol < eol)
goto again;
}
Expand Down
9 changes: 8 additions & 1 deletion t/t7002-grep.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ test_expect_success setup '
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
'
Expand All @@ -48,6 +49,12 @@ do
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
Expand Down

0 comments on commit 8e105e3

Please sign in to comment.