threads / discuss / 46442

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

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

## tl;dr

3 messages between Jul 23, 2017 and Jul 24, 2017.

replies: 2people: 3as markdown or json

Orgad Shaneh· Jul 23, 2017, 06:02 UTC · lore
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· Jul 23, 2017, 08:10 UTC · re: Orgad Shaneh · lore

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

On Sat, Jul 22, 2017 at 11:02 PM, Orgad Shaneh <orgads@gmail.com> wrote:
Show 7 quoted lines
> 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· Jul 24, 2017, 17:41 UTC · re: Jacob Keller · lore

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

On 07/23, Jacob Keller wrote:
Show 13 quoted lines
> 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

← back to recent threads