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

Re: [PATCH 3/4] last-modified: check pathspec against Bloom filter first

From
Jeff King <peff@peff.net>
Date
Jul 20, 2026, 09:42 UTC
Message-ID
<20260720094218.GA681989@coredump.intra.peff.net>
In-Reply-To
<alvulw2fk67duo8n@com-79390>
On Sat, Jul 18, 2026 at 04:22:31PM -0500, Taylor Blau wrote:
Show 30 quoted lines
> 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
Previous: Taylor BlauNext: Toon Claes
Message 13 of 30 in “last-modified: use the pathspec's Bloom key to pre-filter commits”
  1. 0/4 last-modified: use the pathspec's Bloom key to pre-filter commitsToon Claes, Jul 17, 2026
  2. 1/4 revision: move bloom keyvec precondition into functionToon Claes, Jul 17, 2026
  3. Jeff KingJul 18, 2026
  4. Toon ClaesAug 5, 2026
  5. Jeff KingAug 5, 2026
  6. 2/4 revision: expose check for paths maybe changed in Bloom filterToon Claes, Jul 17, 2026
  7. Junio C HamanoJul 17, 2026
  8. Taylor BlauJul 17, 2026
  9. 3/4 last-modified: check pathspec against Bloom filter firstToon Claes, Jul 17, 2026
  10. Taylor BlauJul 17, 2026
  11. Jeff KingJul 18, 2026
  12. Taylor BlauJul 18, 2026
  13. Jeff KingJul 20, 2026
  14. 4/4 last-modified: keep per-path Bloom filters for wildcard pathspecsToon Claes, Jul 17, 2026
  15. Toon ClaesJul 17, 2026
  16. Jeff KingJul 18, 2026
  17. Junio C HamanoAug 4, 2026
  18. Taylor BlauAug 5, 2026
  19. Junio C HamanoAug 5, 2026
  20. Jeff KingAug 5, 2026
  21. Taylor BlauJul 17, 2026
  22. Toon ClaesJul 17, 2026
  23. 0/6 last-modified: use the pathspec's Bloom key to pre-filter commitsToon Claes, Aug 7, 2026
  24. 1/6 revision: move bloom keyvec precondition into functionToon Claes, Aug 7, 2026
  25. 2/6 revision: expose check for paths maybe changed in Bloom filterToon Claes, Aug 7, 2026
  26. 3/6 bloom: add helper to check if any key in a vector is presentToon Claes, Aug 7, 2026
  27. 4/6 revision: add Bloom check that includes parent directoriesToon Claes, Aug 7, 2026
  28. 5/6 last-modified: check pathspec against Bloom filter firstToon Claes, Aug 7, 2026
  29. 6/6 last-modified: keep per-path Bloom filters for wildcard pathspecsToon Claes, Aug 7, 2026
  30. Junio C HamanoAug 8, 2026

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.