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

Re: [bug] git log --invert-grep --grep=[sufficiently complicated regex] prints nothing

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Nov 24, 2022, 15:53 UTC
Message-ID
<221124.861qpspckm.gmgdl@evledraar.gmail.com>
In-Reply-To
<cfbd647e-0e66-4417-8c94-c8cac905a78a@app.fastmail.com>
On Thu, Nov 24 2022, Zack Weinberg wrote:
Show 10 quoted lines
> On Thu, Nov 24, 2022, at 5:31 AM, Phillip Wood wrote:
> [...]
>> I'm afraid I'm not 
>> familiar with the --follow code so I've no idea how to fix this.
>
> I'm honestly unsure what the right behavior _should_ be, now.  I
> expected --grep to be applied very late in the process, after the
> set of commits touching the specified file had already been computed
> (including all of its previous names, because of --follow) but the
> documentation is ambiguous.

This doesn't help with your case, but I remember there being some similar confusions and/or expectations mismatches reported in the patch. E.g. "--since" here: https://lore.kernel.org/git/220401.86pmm1nmvh.gmgdl@evledraar.gmail.com/

I couldn't find a reference quickly, but I seem to recall (but perhaps I'm imagining it) that we had a report/discussion semi-recently about:

	git log --reverse --follow -- path
Which has a similar edge case, e.g. try on git.git:
	git log --reverse --follow -- object-name.c

That's also "correct" if you look at it from the POV of how we implement it, i.e. we'll traverse, and the rename to object-name.c is the first time we encounter the name from the POV of the walking logic.

Hrm, but shouldn't we show all commits *after* the rename then? Anyway, I haven't thought about it this time around, just wanted to provide some rabbit-hole references in case you're interested.

In terms of optimization it's *very* useful that we take these shortcuts, but as your (and some of these) examples show it can yield the wrong or unexpected result in some cases, and in those cases we usually have no non-brute-force way of getting the "right" (or "desired") result other (brute force being: parse "git log -p" yourself).

So it would be nice in general if we had some ability to say what filters apply at what stage in the walk, but I suspect that would require a rather large UX overhaul...

Previous: Zack WeinbergNext: Jeff King
Message 4 of 5 in “[bug] git log --invert-grep --grep=[sufficiently complicated regex] prints nothing”
  1. Zack WeinbergNov 23, 2022
  2. Phillip WoodNov 24, 2022
  3. Zack WeinbergNov 24, 2022
  4. Ævar Arnfjörð BjarmasonNov 24, 2022
  5. Jeff KingNov 24, 2022

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.