Git development
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Taylor Blau <ttaylorr@openai.com>
Cc: Toon Claes <toon@iotcl.com>,
	git@vger.kernel.org, Gusted <gusted@codeberg.org>
Subject: Re: [PATCH 3/4] last-modified: check pathspec against Bloom filter first
Date: Mon, 20 Jul 2026 05:42:18 -0400	[thread overview]
Message-ID: <20260720094218.GA681989@coredump.intra.peff.net> (raw)
In-Reply-To: <alvulw2fk67duo8n@com-79390>

On Sat, Jul 18, 2026 at 04:22:31PM -0500, Taylor Blau wrote:

> I think that we could feasibly get rid of "d" in the output in this
> particular case within last-modified. As you note, the command is marked
> EXPERIMENTAL for a reason, after all ;-).
> 
> If we wanted to do that, it should be straightforward to do. I think the
> following (untested) patch would be sufficient:
> 
> --- 8< ---
> diff --git a/builtin/last-modified.c b/builtin/last-modified.c
> index adc7cd8c74..0f0c1d1d17 100644
> --- a/builtin/last-modified.c
> +++ b/builtin/last-modified.c
> @@ -103,7 +103,7 @@ struct last_modified_callback_data {
>  };
> 
>  static void add_path_from_diff(struct diff_queue_struct *q,
> -			       struct diff_options *opt UNUSED, void *data)
> +			       struct diff_options *opt, void *data)
>  {
>  	struct last_modified *lm = data;
> 
> @@ -112,6 +112,11 @@ static void add_path_from_diff(struct diff_queue_struct *q,
>  		struct last_modified_entry *ent;
>  		const char *path = p->two->path;
> 
> +		if (!match_pathspec(opt->repo->index, &opt->pathspec, path,
> +				    strlen(path), 0, NULL,
> +				    S_ISDIR(p->two->mode)))
> +			continue;
> +

Yeah, that was exactly what I was thinking, but I wasn't sure if
match_pathspec() was the right tool. I mean, obviously it sounds like it
should be from the name, but I don't think it is actually what is used
in tree-diffs! There we have tree-walk.c:do_match() which does some
magic. And match_pathspec() is used more for dir.c callers.

I guess the two are supposed to be equivalent, or else we'd have weird
discrepancies between commands. So maybe just a weird existing oddity
that we don't need to worry about here.

There is one other interesting corner case here. If I do this in
git.git, for example:

  git last-modified -t Documentation/technical/

it shows an entry for Documentation/, which we both find weird. And the
patch above would remove that. But it also shows an entry for
Documentation/technical/, which _is_ within the pathspec and would still
be shown after the patch above. That's OK for the optimization we're
talking about (it would be part of the filter key), but I do find it
still a little funny. The invocation above, at least as we used to use
it as blame-tree at GitHub, is really about asking for the entries
inside that directory, not the directory itself.

Perhaps not worth worrying too much about, though. The caller can easily
ignore the extra entry.

> If, on the other hand, we wanted to retain "d" in the output (which I am
> inclined to suggest is a bad idea), we could keep a list of paths which
> are not covered by the given pathspec.

Yeah, your analysis here makes sense, but I agree that it is not worth
retaining "d". Besides reducing our ability to optimize, it is IMHO just
plain confusing to have in the output.

-Peff

  reply	other threads:[~2026-07-20  9:42 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-17 15:46 [PATCH 0/4] last-modified: use the pathspec's Bloom key to pre-filter commits Toon Claes
2026-07-17 15:46 ` [PATCH 1/4] revision: move bloom keyvec precondition into function Toon Claes
2026-07-18  7:57   ` Jeff King
2026-07-17 15:47 ` [PATCH 2/4] revision: expose check for paths maybe changed in Bloom filter Toon Claes
2026-07-17 20:47   ` Junio C Hamano
2026-07-17 23:26     ` Taylor Blau
2026-07-17 15:47 ` [PATCH 3/4] last-modified: check pathspec against Bloom filter first Toon Claes
2026-07-17 23:05   ` Taylor Blau
2026-07-18  8:37     ` Jeff King
2026-07-18 21:22       ` Taylor Blau
2026-07-20  9:42         ` Jeff King [this message]
2026-07-17 15:47 ` [PATCH 4/4] last-modified: keep per-path Bloom filters for wildcard pathspecs Toon Claes
2026-07-17 19:16   ` Toon Claes
2026-07-18  8:14     ` Jeff King
2026-07-17 23:18   ` Taylor Blau
2026-07-17 19:13 ` [PATCH 0/4] last-modified: use the pathspec's Bloom key to pre-filter commits Toon Claes

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

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

  git send-email \
    --in-reply-to=20260720094218.GA681989@coredump.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gusted@codeberg.org \
    --cc=toon@iotcl.com \
    --cc=ttaylorr@openai.com \
    /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.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox