Skip to content

"git grep" with "-F" (--fixed-strings) option doesn't work when "/" at top of search string #2109

Closed
@zawataki

Description

@zawataki
  • I was not able to find an open or closed issue matching what I'm seeing

Setup

  • Which version of Git for Windows are you using? Is it 32-bit or 64-bit?
$ git --version --build-options
git version 2.21.0.windows.1
cpu: x86_64
built from commit: 2481c4cbe949856f270a3ee80c802f5dd89381aa
sizeof-long: 4
sizeof-size_t: 8
  • Which version of Windows are you running? Vista, 7, 8, 10? Is it 32-bit or 64-bit?
$ cmd.exe /c ver

Microsoft Windows [Version 10.0.17134.523]
  • What options did you set as part of the installation? Or did you choose the
    defaults?
# One of the following:
> type "C:\Program Files\Git\etc\install-options.txt"
> type "C:\Program Files (x86)\Git\etc\install-options.txt"
> type "%USERPROFILE%\AppData\Local\Programs\Git\etc\install-options.txt"
$ cat /etc/install-options.txt
Editor Option: VIM
Custom Editor Path:
Path Option: Cmd
SSH Option: OpenSSH
CURL Option: OpenSSL
CRLF Option: CRLFCommitAsIs
Bash Terminal Option: MinTTY
Performance Tweaks FSCache: Enabled
Use Credential Manager: Enabled
Enable Symlinks: Enabled
  • Any other interesting things about your environment that might be related
    to the issue you're seeing?

Maybe nothing.

Details

  • Which terminal/shell are you running Git from? e.g Bash/CMD/PowerShell/other

Git Bash (C:\Program Files\Git\git-bash.exe)

~ $ mkdir test
~ $ cd test
~/test $ ls -lA
total 0
~/test $ echo "/foo" > testfile
~/test $ git init
Initialized empty Git repository in C:/Users/username/test/.git/
~/test (master) $ git add .
~/test (master) $ git commit -m 'init'
[master (root-commit) 580d85b] init
 1 file changed, 1 insertion(+)
 create mode 100644 testfile
~/test (master) $ git status
On branch master
nothing to commit, working tree clean
~/test (master) $ cat testfile
/foo
~/test (master) $ ls -lA
total 5
drwxr-xr-x 1 username 1049089 0 Mar  6 15:12 .git/
-rw-r--r-- 1 username 1049089 5 Mar  6 15:11 testfile
~/test (master) $ git grep -F 'foo'
testfile:/foo
~/test (master) $ git grep -F '/foo'
~/test (master) $ git grep -F '//foo'
testfile:/foo
  • What did you expect to occur after running these commands?

I expected "testfile:/foo" will be shown after git grep -F '/foo'.

  • What actually happened instead?

Showed nothing.

  • If the problem was occurring with a specific repository, can you provide the
    URL to that repository to help us with testing?

I hope you face the same issue by the commands that I showed. But if not, I will create a repository and provide the URL.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions