Subject: Re: Change the grep command called by git with alternative tools, such as ug.

From: Jonathan Nieder <[email-masked]>
Date: Thu, 2 Jan 2025 16:28:23 +0100

Hi,

Matěj Cepl wrote:
> On Thu Jan 2, 2025 at 2:39 PM CET, Hongyi Zhao wrote:

>> Do you mean: by linking ug as git-ug will do the trick?
>
> No, you would have to rewrite git-grep to use external grep-like
> program. I am not sure whether there isn’t such project already
> out there.

The key question is - what are you trying to do?  "git grep" is able
to search inside historical commits, the working copy, the index, and
so on.  Do we want to search in the same way to find files with hits
(for efficiency reasons, for example) and then use an external program
to find the matches within those files?  For that kind of application
I might do some scripting around "git grep --name-only", but I can
also imagine that your application is different.  Depending on the
goal, it could be something a git command already supports, an implied
feature request for git, or something that the external search tool
might need to learn.

In other words, Matěj's reply is spot on in describing the current
behavior: "git grep" doesn't call out to an external grep tool.  But
as for the desired behavior, we'd need to know more about the use case
to figure it out.

Thanks,
Jonathan