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

Re: bug: `git log --grep ... --invert-grep --author=...` negates / ignores --author

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
May 31, 2017, 18:08 UTC
Message-ID
<CACBZZX7OhdRM+Mhx4FVX-Upvq169ZLvArL5ZxcTgz8u=WRh3aw@mail.gmail.com>
In-Reply-To
<CA+dzEBn4EKzDqS0pCHHsPtGGJc1orf5weKKh0GN-GkE+fVYGcg@mail.gmail.com>
On Wed, May 31, 2017 at 5:45 PM, Anthony Sottile <asottile@umich.edu> wrote:
Show 51 quoted lines
> Given the following commits:
> ```
> asottile@asottile-VirtualBox:/tmp$ git init test
> Initialized empty Git repository in /tmp/test/.git/
> asottile@asottile-VirtualBox:/tmp$ cd test/
> asottile@asottile-VirtualBox:/tmp/test$
> GIT_COMMITTER_EMAIL=foo@example.com GIT_AUTHOR_EMAIL=foo@example.com
> git commit --allow-empty -m "foo"
> [master (root-commit) c9df62b] foo
> asottile@asottile-VirtualBox:/tmp/test$ git commit -m "blah" --allow-empty
> [master 9e3ee9b] blah
> asottile@asottile-VirtualBox:/tmp/test$ git log
> commit 9e3ee9bc1adab2ae8eb1884a8f6237da18dfd27b
> Author: Anthony Sottile <asottile@umich.edu>
> Date:   Wed May 31 08:40:59 2017 -0700
>
>     blah
>
> commit c9df62b93298a247fcfbe24ed4282ccf95448f47
> Author: Anthony Sottile <foo@example.com>
> Date:   Wed May 31 08:40:49 2017 -0700
>
>     foo
> asottile@asottile-VirtualBox:/tmp/test$ git log --grep bar
> --invert-grep --author=foo
> commit 9e3ee9bc1adab2ae8eb1884a8f6237da18dfd27b
> Author: Anthony Sottile <asottile@umich.edu>
> Date:   Wed May 31 08:40:59 2017 -0700
>
>     blah
>
> commit c9df62b93298a247fcfbe24ed4282ccf95448f47
> Author: Anthony Sottile <foo@example.com>
> Date:   Wed May 31 08:40:49 2017 -0700
>
>     foo
> asottile@asottile-VirtualBox:/tmp/test$ git log --author=foocommit
> c9df62b93298a247fcfbe24ed4282ccf95448f47
> Author: Anthony Sottile <foo@example.com>
> Date:   Wed May 31 08:40:49 2017 -0700
>
>     foo
> ```
>
> I expect the same output from the last two commands, but the
> `--invert-grep` one seems to match _all_ the commits.
>
> I can try and dig into this if I have time, just trying to get a count
> using this as a workaround
>
> git log --grep ... --invert-grep --format=%ce | grep ... | wc -l

I had to squint a bit to see what you were getting at here, which is pretty simple: When you provide --invert-grep the --author filter is completely discarded. This is a bug.

I.e. on git.git:
OK:
$ git log --grep=bar --author=Ævar --pretty=format:%an -100 origin/pu
|sort|uniq -c|sort -nr
5 Ævar Arnfjörð Bjarmason

$ git log --author=Ævar --pretty=format:%an -100 origin/pu |sort|uniq -c|sort -nr 100 Ævar Arnfjörð Bjarmason

$ git log --grep=bar --invert-grep --author=Ævar --pretty=format:%an
-100 origin/pu |sort|uniq -c|sort -nr
     78 Junio C Hamano
     14 Jeff King
      2 Andreas Heiduk
      1 Sahil Dua
      1 Rikard Falkeborn
      1 Johannes Sixt
      1 Johannes Schindelin
      1 Ben Peart
      1 Ævar Arnfjörð Bjarmason

That last command should only find my commits, but instead --author is discarded.

Previous: Anthony SottileNext: Jeff King
Message 2 of 7 in “bug: `git log --grep ... --invert-grep --author=...` negates / ignores --author”
  1. Anthony SottileMay 31, 2017
  2. Ævar Arnfjörð BjarmasonMay 31, 2017
  3. Jeff KingMay 31, 2017
  4. Ævar Arnfjörð BjarmasonJun 1, 2017
  5. Anthony SottileJun 1, 2017
  6. Junio C HamanoJun 1, 2017
  7. Junio C HamanoJun 1, 2017

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.