Subject: Re: [PATCH 09/11] midx-write.c: factor out common want_included_pack() routine

From: Junio C Hamano <[email-masked]>
Date: Mon, 25 Mar 2024 13:36:48 -0700

Taylor Blau <[email-masked]> writes:

> diff --git a/midx-write.c b/midx-write.c
> index 89e325d08e..2f0f5d133f 100644
> --- a/midx-write.c
> +++ b/midx-write.c
> @@ -1349,6 +1349,24 @@ static int compare_by_mtime(const void *a_, const void *b_)
>  	return 0;
>  }
>  
> +static int want_included_pack(struct repository *r,
> +			      struct multi_pack_index *m,
> +			      int pack_kept_objects,
> +			      uint32_t pack_int_id)
> +{
> +	struct packed_git *p;
> +	if (prepare_midx_pack(r, m, pack_int_id))
> +		return 0;
> +	p = m->packs[pack_int_id];
> +	if (!pack_kept_objects && p->pack_keep)
> +		return 0;
> +	if (p->is_cruft)
> +		return 0;
> +	if (open_pack_index(p) || !p->num_objects)
> +		return 0;
> +	return 1;
> +}

OK, makes sense to return false when we do not want the caller
proceed with the pack for a function whose name is want_*_pack().