From: Patrick Steinhardt <ps@pks.im>
To: Junio C Hamano <gitster@pobox.com>
Cc: git@vger.kernel.org, Elijah Newren <newren@gmail.com>,
Justin Tobler <jltobler@gmail.com>
Subject: Re: [PATCH v3 1/6] odb: introduce interface to generate packfiles
Date: Fri, 21 Aug 2026 08:28:46 +0200 [thread overview]
Message-ID: <aofwHhFeeWgh_3FY@pks.im> (raw)
In-Reply-To: <xmqqik54soy0.fsf@gitster.g>
On Thu, Aug 20, 2026 at 10:04:55AM -0700, Junio C Hamano wrote:
> Patrick Steinhardt <ps@pks.im> writes:
> > diff --git a/odb.c b/odb.c
> > index caf1d0f542..cd9d5b48bc 100644
> > --- a/odb.c
> > +++ b/odb.c
> > @@ -1046,6 +1046,27 @@ bool odb_optimize_required(struct object_database *odb,
> > return odb_source_optimize_required(odb->sources, opts);
> > }
> >
> > +void odb_generate_pack_options_release(struct odb_generate_pack_options *opts)
> > +{
> > + oid_array_clear(&opts->wants);
> > + oid_array_clear(&opts->haves);
> > + oid_array_clear(&opts->shallows);
> > +}
> > +
> > +int odb_generate_pack(struct object_database *odb,
> > + struct odb_pack_generator **out,
> > + const struct odb_generate_pack_options *opts)
> > +{
> > + if (!odb->sources->generate_pack)
> > + return error(_("primary object source does not support generating packfiles"));
> > + return odb_source_generate_pack(odb->sources, out, opts);
> > +}
>
> Perhaps a stupid question but the opts->pack_fd is documented:
>
> > +struct odb_generate_pack_options {
> > ...
> > + /*
> > + * File descriptor that the generated pack shall be written to. If set
> > + * to `-1`, a pipe will be created and exposed via the pack generator's
> > + * `out` field. If set to `0`, the pack will be written to the standard
> > + * output stream. Otherwise, the provided descriptor will be written to
> > + * and is consumed by the generator.
> > + */
> > + int pack_fd;
> > +
>
> Here I assume that "and is consumed by" refers to "generator writes
> into it and then closes it when it is done"?
Yes.
> odb_source_generate_pack() delegate to source->generate_pack(),
> which I presume goes to odb_source_files_generate_pack(), which in
> turn assigns opts->pack_fd to cp->out and calls start_command(cp) to
> run pack-objects. The file descriptor is closed when the process
> finishes.
Exactly.
> What happens if the odb->sources[0] does not support .generate_pack?
If it does not support generating packs then Git would crash as this is
a non-optional callback. All sources that could be our primary source
though do support it, and the expectation is that any future backends
would know how to implement it, too.
> Should opts->pack_fd be "consumed" here to avoid leaking it, or we
> do not have to worry about it because the caller will soon exit
> itself?
So this case here should not ever happen -- if we don't have the
callback, then there's nothing that can even set `pack_fd` and we should
die.
Patrick
next prev parent reply other threads:[~2026-08-21 6:28 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-07 10:45 [PATCH 0/5] odb: make packfile generation pluggable Patrick Steinhardt
2026-08-07 10:45 ` [PATCH 1/5] odb: introduce interface to generate packfiles Patrick Steinhardt
2026-08-07 10:45 ` [PATCH 2/5] upload-pack: generate packfiles via the object database Patrick Steinhardt
2026-08-07 10:45 ` [PATCH 3/5] send-pack: " Patrick Steinhardt
2026-08-07 10:45 ` [PATCH 4/5] builtin/bundle: refactor option handling for progress meter Patrick Steinhardt
2026-08-07 10:45 ` [PATCH 5/5] bundle: generate packfiles via the object database Patrick Steinhardt
2026-08-13 18:00 ` Junio C Hamano
2026-08-14 7:40 ` Patrick Steinhardt
2026-08-07 21:05 ` [PATCH 0/5] odb: make packfile generation pluggable Junio C Hamano
2026-08-10 5:25 ` Patrick Steinhardt
2026-08-12 23:41 ` Taylor Blau
[not found] ` <an1ajMjVRUsfu-lv@pks.im>
2026-08-13 17:35 ` Junio C Hamano
2026-08-17 5:39 ` [PATCH v2 0/6] " Patrick Steinhardt
2026-08-17 5:39 ` [PATCH v2 1/6] odb: introduce interface to generate packfiles Patrick Steinhardt
2026-08-19 16:56 ` Elijah Newren
2026-08-20 6:01 ` Patrick Steinhardt
2026-08-21 4:41 ` Elijah Newren
2026-08-21 6:34 ` Patrick Steinhardt
2026-08-17 5:39 ` [PATCH v2 2/6] upload-pack: generate packfiles via the object database Patrick Steinhardt
2026-08-17 5:39 ` [PATCH v2 3/6] send-pack: " Patrick Steinhardt
2026-08-17 5:39 ` [PATCH v2 4/6] builtin/bundle: refactor option handling for progress meter Patrick Steinhardt
2026-08-17 5:39 ` [PATCH v2 5/6] bundle: get (mostly) rid of `the_repository` Patrick Steinhardt
2026-08-17 16:47 ` Junio C Hamano
2026-08-18 5:26 ` Patrick Steinhardt
2026-08-21 5:42 ` Elijah Newren
2026-08-21 7:46 ` Patrick Steinhardt
2026-08-17 5:39 ` [PATCH v2 6/6] bundle: generate packfiles via the object database Patrick Steinhardt
2026-08-19 21:52 ` Justin Tobler
2026-08-20 6:01 ` Patrick Steinhardt
2026-08-20 7:55 ` [PATCH v3 0/6] odb: make packfile generation pluggable Patrick Steinhardt
2026-08-20 7:55 ` [PATCH v3 1/6] odb: introduce interface to generate packfiles Patrick Steinhardt
2026-08-20 10:16 ` Karthik Nayak
2026-08-20 11:38 ` Patrick Steinhardt
2026-08-20 17:04 ` Junio C Hamano
2026-08-21 6:28 ` Patrick Steinhardt [this message]
2026-08-20 7:55 ` [PATCH v3 2/6] upload-pack: generate packfiles via the object database Patrick Steinhardt
2026-08-20 10:24 ` Karthik Nayak
2026-08-20 11:38 ` Patrick Steinhardt
2026-08-20 21:11 ` Karthik Nayak
2026-08-20 7:55 ` [PATCH v3 3/6] send-pack: " Patrick Steinhardt
2026-08-20 7:55 ` [PATCH v3 4/6] builtin/bundle: refactor option handling for progress meter Patrick Steinhardt
2026-08-20 11:17 ` Karthik Nayak
2026-08-20 7:55 ` [PATCH v3 5/6] bundle: get (mostly) rid of `the_repository` Patrick Steinhardt
2026-08-20 7:55 ` [PATCH v3 6/6] bundle: generate packfiles via the object database Patrick Steinhardt
2026-08-20 11:19 ` Karthik Nayak
2026-08-20 11:38 ` Patrick Steinhardt
2026-08-20 11:20 ` [PATCH v3 0/6] odb: make packfile generation pluggable Karthik Nayak
2026-08-20 11:40 ` Patrick Steinhardt
2026-08-21 6:05 ` Elijah Newren
2026-08-21 6:30 ` [PATCH v4 " Patrick Steinhardt
2026-08-21 6:30 ` [PATCH v4 1/6] odb: introduce interface to generate packfiles Patrick Steinhardt
2026-08-21 6:30 ` [PATCH v4 2/6] upload-pack: generate packfiles via the object database Patrick Steinhardt
2026-08-21 6:30 ` [PATCH v4 3/6] send-pack: " Patrick Steinhardt
2026-08-21 6:30 ` [PATCH v4 4/6] builtin/bundle: refactor option handling for progress meter Patrick Steinhardt
2026-08-21 6:30 ` [PATCH v4 5/6] bundle: get (mostly) rid of `the_repository` Patrick Steinhardt
2026-08-21 6:30 ` [PATCH v4 6/6] bundle: generate packfiles via the object database Patrick Steinhardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aofwHhFeeWgh_3FY@pks.im \
--to=ps@pks.im \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jltobler@gmail.com \
--cc=newren@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox