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

Re: [PATCH 3/4] pack-bitmap.c: support 'tree:0' filtering

From
Junio C Hamano <gitster@pobox.com>
Date
May 5, 2020, 05:25 UTC
Message-ID
<xmqq7dxrc5r9.fsf@gitster.c.googlers.com>
In-Reply-To
<87b21d72bb588f7366d928544aeaf4de68b027a7.1588633810.git.me@ttaylorr.com>
Taylor Blau <me@ttaylorr.com> writes:
Show 11 quoted lines
> diff --git a/pack-bitmap.c b/pack-bitmap.c
> index 3693c9e62f..195ee8cad0 100644
> --- a/pack-bitmap.c
> +++ b/pack-bitmap.c
> @@ -749,7 +749,7 @@ static void filter_bitmap_exclude_type(struct bitmap_index *bitmap_git,
>  	eword_t mask;
>  	uint32_t i;
>  
> -	if (type != OBJ_BLOB)
> +	if (type != OBJ_BLOB && type != OBJ_TREE)
>  		BUG("filter_bitmap_exclude_type: unsupported type '%d'", type);

OK. This is the same as the previous step, but why would we even need this guard? find_tip_objects() is equipped to find tips of any object type, iterating on the bitmap for "type", or flipping the bits in the to_filter bitmap, does not have any limitation to the blob type in the previous step, and there is no limitation to the blob or tree types after this step, either, no?

Show 11 quoted lines
> @@ -867,6 +867,20 @@ static void filter_bitmap_blob_limit(struct bitmap_index *bitmap_git,
>  	bitmap_free(tips);
>  }
>  
> +static void filter_bitmap_tree_depth(struct bitmap_index *bitmap_git,
> +				     struct object_list *tip_objects,
> +				     struct bitmap *to_filter,
> +				     unsigned long limit)
> +{
> +	if (limit)
> +		BUG("filter_bitmap_tree_depth given non-zero limit");

This one does make sense, because the code to exclude all trees and all blobs we have below won't be able to cull only trees at a given depth or deeper.

> +	filter_bitmap_exclude_type(bitmap_git, tip_objects, to_filter,
> +				   OBJ_TREE);
> +	filter_bitmap_exclude_type(bitmap_git, tip_objects, to_filter,
> +				   OBJ_BLOB);
And these two are quite straight-forward.
Show 15 quoted lines
> +}
> +
>  static int filter_bitmap(struct bitmap_index *bitmap_git,
>  			 struct object_list *tip_objects,
>  			 struct bitmap *to_filter,
> @@ -890,6 +904,15 @@ static int filter_bitmap(struct bitmap_index *bitmap_git,
>  		return 0;
>  	}
>  
> +	if (filter->choice == LOFC_TREE_DEPTH &&
> +	    filter->tree_exclude_depth == 0) {
> +		if (bitmap_git)
> +			filter_bitmap_tree_depth(bitmap_git, tip_objects,
> +						 to_filter,
> +						 filter->tree_exclude_depth);

I briefly wondered if it is cleaner to read if we hardcode 0 as the last argument. But if the helper function ever learns how to filter by tree with non-zero depth, we can only tweak the if() condition without changing the call, so the way you wrote it is the right way.

Thanks.
Previous: Taylor BlauNext: Taylor Blau
Message 7 of 12 in “pack-bitmap: use bitmaps for traversals with '--filter=tree:0'”
  1. 0/4 pack-bitmap: use bitmaps for traversals with '--filter=tree:0'Taylor Blau, May 4, 2020
  2. 1/4 list-objects-filter: treat NULL filter_options as "disabled"Taylor Blau, May 4, 2020
  3. Junio C HamanoMay 5, 2020
  4. 2/4 pack-bitmap.c: make object filtering functions genericTaylor Blau, May 4, 2020
  5. Junio C HamanoMay 5, 2020
  6. 3/4 pack-bitmap.c: support 'tree:0' filteringTaylor Blau, May 4, 2020
  7. Junio C HamanoMay 5, 2020
  8. Taylor BlauMay 5, 2020
  9. Junio C HamanoMay 5, 2020
  10. 4/4 pack-bitmap: pass object filter to fill-in traversalTaylor Blau, May 4, 2020
  11. Junio C HamanoMay 5, 2020
  12. Taylor BlauMay 5, 2020

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.