Hello,
File contents can be searched also by the means of the program call “git grep”. Would you become interested to find specified items only once in each file (instead of multiple times)?
Regards, Markus
threads / discuss / 63748
Subject: How to restrict command “git grep” to the first search result per file?
Hello,
File contents can be searched also by the means of the program call “git grep”. Would you become interested to find specified items only once in each file (instead of multiple times)?
Regards, Markus
Re: How to restrict command “git grep” to the first search result per file?
On Jul 06 2025, Markus Elfring wrote:
> File contents can be searched also by the means of the program call “git grep”. > Would you become interested to find specified items only once in each file > (instead of multiple times)?
Does "git grep -l" suit your needs?
-- Andreas Schwab, schwab@linux-m68k.org GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA AEC1 "And now for something completely different."
Re: How to restrict command “git grep” to the first search result per file?
>> Would you become interested to find specified items only once in each file >> (instead of multiple times)? > > Does "git grep -l" suit your needs?
I imagine that it can occasionally matter see a bit more context for a search result besides a file name.
Regards, Markus
Re: How to restrict command “git grep” to the first search result per file?
> Does "git grep -l" suit your needs?
Is it possible to determine such information also by a corresponding function (instead of the mentioned program call interface)?
Would you occasionally like to transfer file details for search results by other application programming interfaces?
Regards, Markus
Re: How to restrict command “git grep” to the first search result per file?
Hi Markus
On 06/07/2025 12:28, Markus Elfring wrote:
> File contents can be searched also by the means of the program call “git grep”. > Would you become interested to find specified items only once in each file > (instead of multiple times)?
Looking at the man page for git grep there is a --max-count option which will limit the number of matches per file.
Thanks
Phillip