From: Kevin Ushey <kevinushey@gmail.com>
To: git@vger.kernel.org
Subject: git grep -E doesn't accept \b word boundaries?
Date: Wed, 3 May 2023 12:04:47 -0700 [thread overview]
Message-ID: <CAJXgQP1j6JYbtikMuWGFn44+FVb3PfmuwiFrxDGLQAYgr92Wfw@mail.gmail.com> (raw)
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
next reply other threads:[~2023-05-03 19:05 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-03 19:04 Kevin Ushey [this message]
2023-05-03 19:35 ` git grep -E doesn't accept \b word boundaries? Junio C Hamano
2023-05-03 20:32 ` Kevin Ushey
2023-05-03 20:45 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=CAJXgQP1j6JYbtikMuWGFn44+FVb3PfmuwiFrxDGLQAYgr92Wfw@mail.gmail.com \
--to=kevinushey@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).