git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* git grep: ^$ false match at end of file
@ 2025-01-09 23:52 Olly Betts
  2025-01-10 11:43 ` Jeff King
  0 siblings, 1 reply; 5+ messages in thread
From: Olly Betts @ 2025-01-09 23:52 UTC (permalink / raw)
  To: git

git grep '^$' seems to match at the end of the file, reporting a line
number one greater than the number of lines in that file.  This does
not match the behaviour of grep.

To reproduce:

$ git init -q git-grep-bug
$ cd git-grep-bug
$ echo test > test.txt
$ git add test.txt
$ git commit -m test
[master (root-commit) 55b48b26] test
 1 file changed, 1 insertion(+)
 create mode 100644 test.txt
$ git grep -n '^$'
test.txt:2:
$ grep -n '^$' test.txt
$

(The -n option isn't required to trigger it.)

I'm using the git 1:2.47.1-1 packages from Debian unstable.  I can also
reproduce with git 1:2.48.0~rc1+next.20250101-1 from Debian
experimental.

Cheers,
    Olly

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-01-13  6:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-09 23:52 git grep: ^$ false match at end of file Olly Betts
2025-01-10 11:43 ` Jeff King
2025-01-10 12:02   ` Jeff King
2025-01-10 12:59     ` Andreas Schwab
2025-01-13  6:26       ` Jeff King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).