git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Bug report: --invert-grep and --author seems to be incompatible.

From
Jehan Pagès <jehan.marmottard@gmail.com>
Date
Jul 13, 2016, 20:14 UTC
Message-ID
<CAFgjPJ_er6QCaYenU=10_935HoKbc=8hqbJku5p6kF2BYkSrjw@mail.gmail.com>
In-Reply-To
<xmqqlh151lst.fsf@gitster.mtv.corp.google.com>
Hi,
On Wed, Jul 13, 2016 at 7:37 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 28 quoted lines
> Jehan Pagès <jehan.marmottard@gmail.com> writes:
>
>>> I think --author=someone greps the "author " field in the commit
>>> object looking for the hit with "someone", and your request asks to
>>> show commits that either do not have "something" or was not written
>>> by "someone", I would guess.
>>
>> Note that I can still see commits with "something", and I can also see
>> commits by "someone" in my results. So my request actually ask for
>> commits which have neither "something" nor are done by "someone".
>>
>> Anyway I don't think that's the expected result, hence is still a bug.
>> Am I wrong?
>
> Unlike "git grep", "git log" works with boolean expression that does
> not explicitly have a way to say "--and" and "--or", so only one
> interpretation has been chosen long time ago.  All the terms are
> ORed together, and then the whole thing can be inverted with
> "--invert-grep".  i.e. you are telling an equivalent of
>
>     $ git grep --not \( -e "author someone" --or -e "something" \)
>
> with the command line, and there is no way to combine the requested
> match criteria (there are two, "author must be somebody" and
> "something must be in the message") differently.
>
> Given that, that is the "right" expectation, and as long as you get
> the behaviour, there is no "bug".

I see. Well it's a little counter-intuitive though, since the option is called --invert-grep. And the man indicates:

« Limit the commits output to ones with log message that do not match the pattern specified with --grep=<pattern>. »

So it gives the impression that the option is made only to invert the --grep part. Whereas in fact, you are saying it inverts any other optional selection (or at least also --author). A better naming should have been called --invert-matches, or even just --invert. And the man description should definitely be completed, IMO.

> You can call it a lack of feature, though, and patches to implement
> a more flexible combination of match criteria like "git grep" allows
> is always welcome.

Maybe I will! This would be useful to have a little more capabilities for commit selection. Thanks.

Jehan
-- 
ZeMarmot open animation film
http://film.zemarmot.net
Patreon: https://patreon.com/zemarmot
Tipeee: https://www.tipeee.com/zemarmot
Previous: Junio C HamanoNext: Junio C Hamano
Message 5 of 6 in “Bug report: --invert-grep and --author seems to be incompatible.”
  1. Jehan PagèsJul 13, 2016
  2. Junio C HamanoJul 13, 2016
  3. Jehan PagèsJul 13, 2016
  4. Junio C HamanoJul 13, 2016
  5. Jehan PagèsJul 13, 2016
  6. Junio C HamanoJul 13, 2016

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.