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

Re: [PATCH v2] bloom: enable bloom filter with wildcard pathspec in revision traversal

From
Lidong Yan <yldhome2d2@gmail.com>
Date
Aug 9, 2025, 02:06 UTC
Message-ID
<B2F0FE14-AA88-490D-989C-3D93BF972DCF@gmail.com>
In-Reply-To
<xmqqsei1izhs.fsf@gitster.g>
Junio C Hamano <gitster@pobox.com> writes:
Show 13 quoted lines
> 
>> @@ -693,9 +698,22 @@ static int convert_pathspec_to_bloom_keyvec(struct bloom_keyvec **out,
>> size_t len;
>> int res = 0;
>> 
>> + len = pi->nowildcard_len;
>> + if (len != pi->len) {
>> + /*
>> + * for path like "/dir/file*", nowildcard part would be
>> + * "/dir/file", but only "/dir" should be used for the
> 
> Leading "/" makes it look as if the pathspec element can begin with
> a slash, but it can not, can it?

Yes, seems like if we pass a absolute path "/path/to/repository/dir/file”, git will automatically move "/path/to/repository” (in setup.c abspath_part_inside_repo()) So I should remove leading slash in my comment.

Show 52 quoted lines
> Taking what I suggested above, here is a possible improvement.
> 
> revision.c | 18 ++++++++----------
> 1 file changed, 8 insertions(+), 10 deletions(-)
> 
> diff --git i/revision.c w/revision.c
> index 2a5b98390e..2a92bdda84 100644
> --- i/revision.c
> +++ w/revision.c
> @@ -696,14 +696,14 @@ static int convert_pathspec_to_bloom_keyvec(struct bloom_keyvec **out,
> char *path_alloc = NULL;
> const char *path;
> size_t len;
> - int res = 0;
> + int res = -1; /* be pessimistic */
> 
> len = pi->nowildcard_len;
> if (len != pi->len) {
> /*
> - * for path like "/dir/file*", nowildcard part would be
> - * "/dir/file", but only "/dir" should be used for the
> - * bloom filter
> + * for path like "dir/file*", nowildcard part would be
> + * "dir/file", but only "dir" should be used for the
> + * bloom filter.
> */
> while (len > 0 && pi->match[len - 1] != '/')
> len--;
> @@ -712,19 +712,17 @@ static int convert_pathspec_to_bloom_keyvec(struct bloom_keyvec **out,
> if (len > 0 && pi->match[len - 1] == '/')
> len--;
> 
> + if (!len)
> + goto cleanup;
> +
> if (len != pi->len) {
> path_alloc = xmemdupz(pi->match, len);
> path = path_alloc;
> } else
> path = pi->match;
> 
> - len = strlen(path);
> - if (!len) {
> - res = -1;
> - goto cleanup;
> - }
> -
> *out = bloom_keyvec_new(path, len, settings);
> + res = 0;
> 
> cleanup:
> free(path_alloc);

Thanks, I will apply this and add your signed-off. Lidong

Previous: Junio C HamanoNext: Lidong Yan
Message 8 of 16 in “bloom: enable bloom filter with wildcard pathspec in revision traversal”
  1. bloom: enable bloom filter with wildcard pathspec in revision traversalLidong Yan, Aug 7, 2025
  2. Patrick SteinhardtAug 7, 2025
  3. Lidong YanAug 7, 2025
  4. Junio C HamanoAug 7, 2025
  5. Lidong YanAug 8, 2025
  6. bloom: enable bloom filter with wildcard pathspec in revision traversalLidong Yan, Aug 8, 2025
  7. Junio C HamanoAug 8, 2025
  8. Lidong YanAug 9, 2025
  9. bloom: enable bloom filter with wildcard pathspec in revision traversalLidong Yan, Aug 9, 2025
  10. bloom: enable bloom filter with wildcard pathspec in revision traversalLidong Yan, Aug 9, 2025
  11. Lidong YanAug 9, 2025
  12. bloom: enable bloom filter with wildcard pathspec in revision traversalLidong Yan, Aug 11, 2025
  13. Junio C HamanoAug 11, 2025
  14. Lidong YanAug 11, 2025
  15. Junio C HamanoAug 9, 2025
  16. Lidong YanAug 10, 2025

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.