# git grep bug replacing - with :

5 messages from 2024-06-14 to 2024-06-15. Participants: Rickard Andersson, Eric Sunshine, Junio C Hamano.
Thread: https://gitlist.dev/t/61633

## Rickard Andersson, 2024-06-14 19:21

Subject: git grep bug replacing - with :
Message-ID: <CALyzih__9sZD31SVMECcxk55+MAMjkfgpLzecoHo0xUoauerqA@mail.gmail.com>
URL: https://gitlist.dev/e/CALyzih__9sZD31SVMECcxk55%2BMAMjkfgpLzecoHo0xUoauerqA%40mail.gmail.com

```
Thank you for filling out a Git bug report!
Please answer the following questions to help us understand your issue.

What did you do before the bug happened? (Steps to reproduce your issue)
   Added 2 files to my repo with words in them
   text-file.txt
   text-file-file.txt

   I did a git grep for said words that exists in both, and used
argument `-l` to only
   show matching filename
   ˋˋˋ
   git grep -l ExtremelyInterestingWord
   ˋˋˋ

What did you expect to happen? (Expected behavior)
   I expected to get the following output
   ˋˋˋ
   text-file.txt
   text-file-file.txt
   ˋˋˋ

What happened instead? (Actual behavior)
   I get
   ˋˋˋ
   text:file.txt
   text:file-file.txt
   ˋˋˋ


What's different between what you expected and what actually happened?
   It seems that when using the argument `-l` the first `-` in a filename is
   replaced with a `:`. It also seems that it is just the first one as the
   second file keeps it's second occurence of `-`.

Anything else you want to add:

Please review the rest of the bug report below.
You can delete any lines you don't wish to share.

[System Info]
git version:
git version 2.34.1
cpu: x86_64
no commit associated with this build
sizeof-long: 8
sizeof-size_t: 8
shell-path: /bin/sh
uname: Linux 6.5.0-35-generic #35~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC
Tue May  7 09:00:52 UTC 2 x86_64
compiler info: gnuc: 11.4
libc info: glibc: 2.35
$SHELL (typically, interactive shell): /usr/bin/zsh

```

## Eric Sunshine, 2024-06-14 19:36

Subject: Re: git grep bug replacing - with :
Message-ID: <CAPig+cRGnAcfpr4JWp9WWC0b4yvjKx-_0up_S2iaXCBxgcSLjQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAPig%2BcRGnAcfpr4JWp9WWC0b4yvjKx-_0up_S2iaXCBxgcSLjQ%40mail.gmail.com
In-Reply-To: <CALyzih__9sZD31SVMECcxk55+MAMjkfgpLzecoHo0xUoauerqA@mail.gmail.com>

```
On Fri, Jun 14, 2024 at 3:22 PM Rickard Andersson
<rickard.a1992@gmail.com> wrote:
> What did you do before the bug happened? (Steps to reproduce your issue)
>    Added 2 files to my repo with words in them
>    text-file.txt
>    text-file-file.txt
>    ˋˋˋ
>    git grep -l ExtremelyInterestingWord
>    ˋˋˋ
>
> What happened instead? (Actual behavior)
>    I get
>    ˋˋˋ
>    text:file.txt
>    text:file-file.txt
>    ˋˋˋ

I am unable to reproduce this problem:

    $ git version
    git version 2.45.2
    $ git init foo
    Initialized empty Git repository in .../foo/.git/
    $ cd foo
    $ echo ExtremelyInterestingWord >text-file.txt
    $ echo ExtremelyInterestingWord >text-file-file.txt
    $ git add text-file.txt text-file-file.txt
    $ git commit -m msg
    [main (root-commit) 765269f] msg
     2 files changed, 2 insertions(+)
     create mode 100644 text-file-file.txt
     create mode 100644 text-file.txt
    $ git grep -l ExtremelyInterestingWord
    text-file-file.txt
    text-file.txt

```

## Junio C Hamano, 2024-06-14 21:05

Subject: Re: git grep bug replacing - with :
Message-ID: <xmqqbk43dyln.fsf@gitster.g>
URL: https://gitlist.dev/e/xmqqbk43dyln.fsf%40gitster.g
In-Reply-To: <CAPig+cRGnAcfpr4JWp9WWC0b4yvjKx-_0up_S2iaXCBxgcSLjQ@mail.gmail.com>

```
Eric Sunshine <sunshine@sunshineco.com> writes:

> On Fri, Jun 14, 2024 at 3:22 PM Rickard Andersson
> <rickard.a1992@gmail.com> wrote:
>> What did you do before the bug happened? (Steps to reproduce your issue)
>>    Added 2 files to my repo with words in them
>>    text-file.txt
>>    text-file-file.txt
>>    ˋˋˋ
>>    git grep -l ExtremelyInterestingWord
>>    ˋˋˋ
>>
>> What happened instead? (Actual behavior)
>>    I get
>>    ˋˋˋ
>>    text:file.txt
>>    text:file-file.txt
>>    ˋˋˋ

If the command line were "git grep -l <pattern> text", and there is
a branch whose name is "text", and in the top level tree of that
"text" branch's commit there are file.txt and file-file.txt both of
which have the pattern, the symptom observed may appear.

But ...

> I am unable to reproduce this problem:
>
>     $ git version
>     git version 2.45.2
>     $ git init foo
>     Initialized empty Git repository in .../foo/.git/
>     $ cd foo
>     $ echo ExtremelyInterestingWord >text-file.txt
>     $ echo ExtremelyInterestingWord >text-file-file.txt
>     $ git add text-file.txt text-file-file.txt
>     $ git commit -m msg
>     [main (root-commit) 765269f] msg
>      2 files changed, 2 insertions(+)
>      create mode 100644 text-file-file.txt
>      create mode 100644 text-file.txt
>     $ git grep -l ExtremelyInterestingWord
>     text-file-file.txt
>     text-file.txt

... with your (i.e. Eric's) reproduction setup, which agrees with
the way how I interpreted the problem description in the original
report, I do not see there is any other possible output from it.

Thanks.

```

## Rickard Andersson, 2024-06-15 10:21

Subject: Re: git grep bug replacing - with :
Message-ID: <CALyzih-5qtezCnizj07Gi0MyoeweXU1Kw5-gnv7YwSg0DC965w@mail.gmail.com>
URL: https://gitlist.dev/e/CALyzih-5qtezCnizj07Gi0MyoeweXU1Kw5-gnv7YwSg0DC965w%40mail.gmail.com
In-Reply-To: <xmqqbk43dyln.fsf@gitster.g>

```
Hello,

Kudos for the very quick response times, nice!

I tried to reproduce this in a more isolated way and did Eric's setup
where the issue was reproduced again. However, I realized I should
test this without my gitconfig and could then isolate the issue to the
pager delta. I then noticed the issue is reported there already:
https://github.com/dandavison/delta/issues/1674.

So this is clearly not an issue in git, I should have tried without my
gitconfig before even sending this bugreport so I hope I didn't
take too much of your time.

Best regards,
Rickard

On Fri, 14 Jun 2024 at 23:05, Junio C Hamano <gitster@pobox.com> wrote:
>
> Eric Sunshine <sunshine@sunshineco.com> writes:
>
> > On Fri, Jun 14, 2024 at 3:22 PM Rickard Andersson
> > <rickard.a1992@gmail.com> wrote:
> >> What did you do before the bug happened? (Steps to reproduce your issue)
> >>    Added 2 files to my repo with words in them
> >>    text-file.txt
> >>    text-file-file.txt
> >>    ˋˋˋ
> >>    git grep -l ExtremelyInterestingWord
> >>    ˋˋˋ
> >>
> >> What happened instead? (Actual behavior)
> >>    I get
> >>    ˋˋˋ
> >>    text:file.txt
> >>    text:file-file.txt
> >>    ˋˋˋ
>
> If the command line were "git grep -l <pattern> text", and there is
> a branch whose name is "text", and in the top level tree of that
> "text" branch's commit there are file.txt and file-file.txt both of
> which have the pattern, the symptom observed may appear.
>
> But ...
>
> > I am unable to reproduce this problem:
> >
> >     $ git version
> >     git version 2.45.2
> >     $ git init foo
> >     Initialized empty Git repository in .../foo/.git/
> >     $ cd foo
> >     $ echo ExtremelyInterestingWord >text-file.txt
> >     $ echo ExtremelyInterestingWord >text-file-file.txt
> >     $ git add text-file.txt text-file-file.txt
> >     $ git commit -m msg
> >     [main (root-commit) 765269f] msg
> >      2 files changed, 2 insertions(+)
> >      create mode 100644 text-file-file.txt
> >      create mode 100644 text-file.txt
> >     $ git grep -l ExtremelyInterestingWord
> >     text-file-file.txt
> >     text-file.txt
>
> ... with your (i.e. Eric's) reproduction setup, which agrees with
> the way how I interpreted the problem description in the original
> report, I do not see there is any other possible output from it.
>
> Thanks.

```

## Eric Sunshine, 2024-06-15 16:36

Subject: Re: git grep bug replacing - with :
Message-ID: <CAPig+cS0LhojBYtc9rEDo0Twb+1yjLy5fodCPOF6++1gmx2MWQ@mail.gmail.com>
URL: https://gitlist.dev/e/CAPig%2BcS0LhojBYtc9rEDo0Twb%2B1yjLy5fodCPOF6%2B%2B1gmx2MWQ%40mail.gmail.com
In-Reply-To: <CALyzih-5qtezCnizj07Gi0MyoeweXU1Kw5-gnv7YwSg0DC965w@mail.gmail.com>

```
On Sat, Jun 15, 2024 at 6:22 AM Rickard Andersson
<rickard.a1992@gmail.com> wrote:
> I tried to reproduce this in a more isolated way and did Eric's setup
> where the issue was reproduced again. However, I realized I should
> test this without my gitconfig and could then isolate the issue to the
> pager delta. I then noticed the issue is reported there already:
> https://github.com/dandavison/delta/issues/1674.
>
> So this is clearly not an issue in git, I should have tried without my
> gitconfig before even sending this bugreport so I hope I didn't
> take too much of your time.

The benefit of having posted here is that there is now a record of it
in the Git mail archive, which may benefit the next person who
encounters the issue (if that person searches the archive). Moreover,
those who followed this thread are now better equipped to point future
reporters at the Delta bug report you cited.

```
