Re: [PATCH 2/4] pack-objects: ensure tree/tag closure with '--stdin-packs=follow'
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 30, 2026, 17:51 UTC
- Message-ID
- <xmqqcxtubpbj.fsf@gitster.g>
- In-Reply-To
- <6348667e2e3fe63aeb139888e877dd8447570253.1790731662.git.me@ttaylorr.com>
Taylor Blau <ttaylorr@openai.com> writes:
Show 10 quoted lines
> @@ -4574,6 +4603,9 @@ static int add_loose_object(const struct object_id *oid, const char *path, > > if (ctx && type == OBJ_COMMIT) > add_pending_oid(ctx->revs, NULL, oid, 0); > + else if (ctx && ctx->mode == STDIN_PACKS_MODE_FOLLOW && > + (type == OBJ_TREE || type == OBJ_TAG)) > + oid_array_append(&ctx->extra_roots, oid); > > return 0; > }
Makes me wonder if this function will always end with "if ctx is not NULL, then depending on these conditions do one more thing" like this, or if it would change later. If the former,
if (!ctx) return 0;
if (type == OBJ_COMMIT) do the commit thing; else if (ctx->mode == follow && type in (tree, tag)) do the tag or tree thing;
return 0;
might be easier to follow, perhaps?