# bug: git grep -P and multiline mode

3 messages from 2014-06-23 to 2014-06-24. Participants: Noel Grandin, Junio C Hamano.
Thread: https://gitlist.dev/t/36979

## Noel Grandin, 2014-06-23 06:54

Subject: bug: git grep -P and multiline mode
Message-ID: <53A7CF25.7060508@gmail.com>
URL: https://gitlist.dev/e/53A7CF25.7060508%40gmail.com

```
Hi

It looks like the perl regular expression multiline mode does not work with 'git grep'

for example, something like

    git grep -P '(?s)foo.*?bar"

will not match a file in the repo where it has something like

    foo
    bar

ie. split across two lines

Regards, Noel Grandin

```

## Junio C Hamano, 2014-06-23 17:42

Subject: Re: bug: git grep -P and multiline mode
Message-ID: <xmqqa993cykl.fsf@gitster.dls.corp.google.com>
URL: https://gitlist.dev/e/xmqqa993cykl.fsf%40gitster.dls.corp.google.com
In-Reply-To: <53A7CF25.7060508@gmail.com>

```
Noel Grandin <noelgrandin@gmail.com> writes:

> It looks like the perl regular expression multiline mode does not work with 'git grep'

Yes, and deliberately so, to avoid having to think about things like
"how would a multi-line match interact with 'grep -n'?"

We behave as if we feed each line of the contents one line at a time
to the matching engine that is chosen by the -P/-E/-G/-F optoins, so
this limitation is unlikely to change.

```

## Noel Grandin, 2014-06-24 07:34

Subject: Re: bug: git grep -P and multiline mode
Message-ID: <53A92A14.8010607@gmail.com>
URL: https://gitlist.dev/e/53A92A14.8010607%40gmail.com
In-Reply-To: <xmqqa993cykl.fsf@gitster.dls.corp.google.com>

```
On 2014-06-23 07:42 PM, Junio C Hamano wrote:
> Noel Grandin <noelgrandin@gmail.com> writes:
>
>> It looks like the perl regular expression multiline mode does not work with 'git grep'
> Yes, and deliberately so, to avoid having to think about things like
> "how would a multi-line match interact with 'grep -n'?"
>
>

Ah, that is a pity.

I find the multi-line mode very useful for finding code problems that span multiple lines.

I'm sure there are other options that conflict, and the solution is to normally write out some kind of informative error 
message?

Anyhow, since I'm too busy working on LibreOffice right now to work up a patch for git, I'll stick to using
     find | xargs grep
:-)

```
