Re: git log -S or -G
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Oct 7, 2018, 00:48 UTC
- Message-ID
- <xmqqd0smvay0.fsf@gitster-ct.c.googlers.com>
- In-Reply-To
- <CACBZZX6PmG=-8563eYE4z98yvHePenZf_Kz1xgpse0ngjB5QyA@mail.gmail.com>
Ævar Arnfjörð Bjarmason <avarab@gmail.com> writes:
Show 12 quoted lines
> On Sat, Oct 6, 2018 at 5:16 PM Julia Lawall <julia.lawall@lip6.fr> wrote: >> Git log -S or -G make it possible to find commits that have particular >> words in the changed lines. Sometimes it would be helpful to search for >> words in the removed lines or in the added lines specifically. From the >> implementation, I had the impression that this would be easy to implement. >> The main question would be how to allow the user to specify what is >> wanted. > > As far as I know this isn't possible. The --diff-filter option is > similar in spirit, but e.g. adding "foo" and then removing it from an > existing file will both be covered under --diff-filter=M, so that > isn't what you're looking for.
I agree with Julia that UI to the feature is harder than the machinery to implement the feature to add "I am interested in seeing a patch that contains a hunk that adds 'foo' but am not interested in removal" (or vice versa) for -G. You tweak diffcore-pickaxe.c::diffgrep_consume() and you'are done.
Doing the same for -S is much harder at the machinery level, as it performs its thing without internally running "diff" twice, but just counts the number of occurrences of 'foo'---that is sufficient for its intended use, and more efficient.