diff --git a/mercurial/commands.py b/mercurial/commands.py --- a/mercurial/commands.py +++ b/mercurial/commands.py @@ -3428,8 +3428,11 @@ m = regexp.search(self.line, p) if not m: break - yield m.span() - p = m.end() + if m.end() == p: + p += 1 + else: + yield m.span() + p = m.end() matches = {} copies = {} diff --git a/tests/test-grep.t b/tests/test-grep.t --- a/tests/test-grep.t +++ b/tests/test-grep.t @@ -660,7 +660,7 @@ $ echo 'added, missing' > added-missing; hg add added-missing; rm added-missing $ echo 'untracked' > untracked $ hg rm old - $ hg grep '[^Z]' + $ hg grep '' added:added new:something else new:modified