# recursive grep doesn't respect --color=always inside submodules

3 messages from 2017-07-23 to 2017-07-24. Participants: Orgad Shaneh, Jacob Keller, Brandon Williams.
Thread: https://gitlist.dev/t/46442

## Orgad Shaneh, 2017-07-23 06:02

Subject: recursive grep doesn't respect --color=always inside submodules
Message-ID: <CAGHpTB+dSGza5Lwg76WXg+pPZ=dz3QdCTnDozWG_y+5_bPor6A@mail.gmail.com>
URL: https://gitlist.dev/e/CAGHpTB%2BdSGza5Lwg76WXg%2BpPZ%3Ddz3QdCTnDozWG_y%2B5_bPor6A%40mail.gmail.com

```
Hi,

When git grep --color=always is used, and the output is redirected to
a file or a pipe, results inside submodules are not colored. Results
in the supermodule are colored correctly.

- Orgad

```

## Jacob Keller, 2017-07-23 08:10

Subject: Re: recursive grep doesn't respect --color=always inside submodules
Message-ID: <CA+P7+xrzLdGN1nkkcTH7iGBo1gg4GgPGYSgvF7-jw6LKj+WiBQ@mail.gmail.com>
URL: https://gitlist.dev/e/CA%2BP7%2BxrzLdGN1nkkcTH7iGBo1gg4GgPGYSgvF7-jw6LKj%2BWiBQ%40mail.gmail.com
In-Reply-To: <CAGHpTB+dSGza5Lwg76WXg+pPZ=dz3QdCTnDozWG_y+5_bPor6A@mail.gmail.com>

```
On Sat, Jul 22, 2017 at 11:02 PM, Orgad Shaneh <orgads@gmail.com> wrote:
> Hi,
>
> When git grep --color=always is used, and the output is redirected to
> a file or a pipe, results inside submodules are not colored. Results
> in the supermodule are colored correctly.
>
> - Orgad

This occurs because color isn't passed to the recursive grep submodule
process we launch. It might be fixed if/when we switch to using the
repository object to run grep in-process. We could also patch grep to
pass the color option into the submodule.

Thanks,
Jake

```

## Brandon Williams, 2017-07-24 17:41

Subject: Re: recursive grep doesn't respect --color=always inside submodules
Message-ID: <20170724174128.GA68104@google.com>
URL: https://gitlist.dev/e/20170724174128.GA68104%40google.com
In-Reply-To: <CA+P7+xrzLdGN1nkkcTH7iGBo1gg4GgPGYSgvF7-jw6LKj+WiBQ@mail.gmail.com>

```
On 07/23, Jacob Keller wrote:
> On Sat, Jul 22, 2017 at 11:02 PM, Orgad Shaneh <orgads@gmail.com> wrote:
> > Hi,
> >
> > When git grep --color=always is used, and the output is redirected to
> > a file or a pipe, results inside submodules are not colored. Results
> > in the supermodule are colored correctly.
> >
> > - Orgad
> 
> This occurs because color isn't passed to the recursive grep submodule
> process we launch. It might be fixed if/when we switch to using the
> repository object to run grep in-process. We could also patch grep to
> pass the color option into the submodule.

This is one of the many downsides to the multi-process approach as it is
very easy to miss passing configuration like '--color' down to the
submodules.  As Jacob pointed out this problem is solved when the
recursion is handled in-process.  The series to implement this is
currently under-review.  The latest version of the patch series you can
find here
(https://public-inbox.org/git/20170718190527.78049-1-bmwill@google.com/)
and it looks like Junio has it as a branch on github at
(https://github.com/gitster/git/tree/bw/grep-recurse-submodules).

-- 
Brandon Williams

```
