git grep -E doesn't accept \b word boundaries?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

I'm seeing the following, which I believe is unexpected. I have a file
with contents:

$ cat hello.txt
WholeWord
Whole Word
Whole

I can use `git grep` to search with word boundaries; e.g.

$ git grep --untracked '\bWhole\b'
hello.txt:Whole Word
hello.txt:Whole

However, if I add `-E` to use extended regular expressions, the same
invocation finds no search results.

$ git grep --untracked -E '\bWhole\b'

This does seem to work as expected with the '-w' flag, e.g.

$ git grep --untracked -E -w 'Whole'
hello.txt:Whole Word
hello.txt:Whole

as well as with POSIX word boundaries, e.g.

$ git grep --untracked -E '[[:<:]]Whole[[:>:]]'
hello.txt:Whole Word
hello.txt:Whole

Is this a bug, or am I misunderstanding some behavior in `git grep`?
For posterity:

$ git grep --untracked -G '\bWhole\b'
hello.txt:Whole Word
hello.txt:Whole

$ git grep --untracked -E '\bWhole\b'

$ git grep --untracked -P '\bWhole\b'
hello.txt:Whole Word
hello.txt:Whole

For what it's worth, I don't see this issue with an older version of
`git` on an Ubuntu 22.04 VM:

root@96722b73f316:~/test# git --version
git version 2.34.1
root@96722b73f316:~/test# git grep --untracked -E '\bWhole\b'
hello.txt:Whole Word
hello.txt:Whole

Thanks,
Kevin

------

[System Info]
git version:
git version 2.40.1
cpu: arm64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
feature: fsmonitor--daemon
uname: Darwin 22.4.0 Darwin Kernel Version 22.4.0: Mon Mar  6 20:59:28
PST 2023; root:xnu-8796.101.5~3/RELEASE_ARM64_T6000 arm64
compiler info: clang: 14.0.3 (clang-1403.0.22.14.1)
libc info: no libc information available
$SHELL (typically, interactive shell): /opt/homebrew/bin/bash



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux