Re: [PATCH v3 4/7] object-file: remove flags from transaction packfile writes
- From
Jeff King <peff@peff.net>
- Date
- Apr 6, 2026, 20:19 UTC
- Message-ID
- <20260406201904.GA26632@coredump.intra.peff.net>
- In-Reply-To
- <20260406201627.GA26312@coredump.intra.peff.net>
On Mon, Apr 06, 2026 at 04:16:28PM -0400, Jeff King wrote:
Show 30 quoted lines
> On Thu, Apr 02, 2026 at 04:32:17PM -0500, Justin Tobler wrote:
>
> > @@ -1667,18 +1685,28 @@ int index_fd(struct index_state *istate, struct object_id *oid,
> > [...]
> > + struct odb_write_stream stream;
> > + odb_write_stream_from_fd(&stream, fd, xsize_t(st->st_size));
> > +
> > + if (flags & INDEX_WRITE_OBJECT) {
> > + struct object_database *odb = the_repository->objects;
> > + struct odb_transaction_files *files_transaction;
> > + struct odb_transaction *transaction;
> > +
> > + transaction = odb_transaction_begin(odb);
> > + files_transaction = container_of(odb->transaction,
> > + struct odb_transaction_files,
> > + base);
> > + ret = index_blob_packfile_transaction(files_transaction, oid, fd,
> > + xsize_t(st->st_size), path);
> > + odb_transaction_commit(transaction);
> > + } else {
> > + ret = hash_blob_stream(&stream,
> > + the_repository->hash_algo, oid,
> > + xsize_t(st->st_size));
> > + }
> > +
> > + odb_write_stream_release(&stream);
>
> Probably not a big deal, but I notice that "stream" is not used in half
> of the conditional. Should its initialization and cleanup be pushed down
> into the else clause?Ah, never mind. I was looking at this patch in isolation as a solution to the segfault problem. But later in the series, you end up converting index_blob_packfile_transaction() to use stream, too, which seems like a good direction.
So it is a little funny at this step, but it reduces the diff later.
-Peff