git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: Zack Weinberg <zack@owlfolio.org>
Cc: phillip.wood@dunelm.org.uk, git@vger.kernel.org
Subject: Re: [bug] git log --invert-grep --grep=[sufficiently complicated regex] prints nothing
Date: Thu, 24 Nov 2022 16:53:28 +0100	[thread overview]
Message-ID: <221124.861qpspckm.gmgdl@evledraar.gmail.com> (raw)
In-Reply-To: <cfbd647e-0e66-4417-8c94-c8cac905a78a@app.fastmail.com>


On Thu, Nov 24 2022, Zack Weinberg wrote:

> 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...

  reply	other threads:[~2022-11-24 16:02 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-23 20:17 [bug] git log --invert-grep --grep=[sufficiently complicated regex] prints nothing Zack Weinberg
2022-11-24 10:31 ` Phillip Wood
2022-11-24 13:36   ` Zack Weinberg
2022-11-24 15:53     ` Ævar Arnfjörð Bjarmason [this message]
2022-11-24 16:35       ` Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=221124.861qpspckm.gmgdl@evledraar.gmail.com \
    --to=avarab@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=phillip.wood@dunelm.org.uk \
    --cc=zack@owlfolio.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).