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

Re: [PATCH 1/2] pack-objects: break out of want_object loop early

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 25, 2016, 19:56 UTC
Message-ID
<xmqqeg6h5w60.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20160725185010.GA12974@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 11 quoted lines
> When pack-objects collects the list of objects to pack
> (either from stdin, or via its internal rev-list), it
> filters each one through want_object_in_pack().
>
> This function loops through each existing packfile, looking
> for the object. When we find it, we mark the pack/offset
> combo for later use. However, we can't just return "yes, we
> want it" at that point. If --honor-pack-keep is in effect,
> we must keep looking to find it in _all_ packs, to make sure
> none of them has a .keep. Likewise, if --local is in effect,
> we must make sure it is not present in any local pack.
s/any local pack/any non-local pack/, no?
Show 12 quoted lines
> diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c
> index a2f8cfd..55ef5a8 100644
> --- a/builtin/pack-objects.c
> +++ b/builtin/pack-objects.c
> @@ -981,6 +981,8 @@ static int want_object_in_pack(const unsigned char *sha1,
>  				return 0;
>  			if (ignore_packed_keep && p->pack_local && p->pack_keep)
>  				return 0;
> +			if (!ignore_packed_keep && !local)
> +				break;
>  		}
>  	}

OK, so in this loop, we may return "false" (meaning, we do not want to pack the object) if "local" (do not pack objects that appear in non-local packs) or "ignore_packed_keep" (do not pack objects that appear in locally kept packs) are in effect, but if neither of the options is set, we know that one of the preconditions ("local" or "ignore_packed_keep") for these two "reject by returning false" if statements would never trigger for any pack on packed_git list, so it is safe to break out and return the one that we have found.

If that is what is going on, I would have expected to see this early break before these "we found that this is available in borrowed pack and we are only packing local" and "we ignore objects in locally kept packs" checks return false.

Or am I not following the logic in the loop correctly?
Previous: Jeff KingNext: Jeff King
Message 3 of 13 in “speed up "Counting objects" when there are many packs”
  1. 0/2 speed up "Counting objects" when there are many packsJeff King, Jul 25, 2016
  2. 1/2 pack-objects: break out of want_object loop earlyJeff King, Jul 25, 2016
  3. Junio C HamanoJul 25, 2016
  4. Jeff KingJul 25, 2016
  5. Junio C HamanoJul 25, 2016
  6. Jeff KingJul 25, 2016
  7. Junio C HamanoJul 26, 2016
  8. Jeff KingJul 26, 2016
  9. Junio C HamanoJul 26, 2016
  10. Jeff KingJul 27, 2016
  11. Junio C HamanoJul 27, 2016
  12. Jeff KingJul 27, 2016
  13. 2/2 pack-objects: compute local/ignore_pack_keep earlyJeff King, Jul 25, 2016

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.