Re: [PATCH 5/6] odb/transaction: add transaction env interface
From: Patrick Steinhardt <hidden>
Date: 2026-06-24 11:26:56
On Tue, Jun 23, 2026 at 11:19:19PM -0500, Justin Tobler wrote:
The ODB transaction backend is responsible for creating/managing its own staging area for writing objects. Other child processes spawned by Git may need to access to uncommitted objects or write new objects in the
s/may need to access to/may need access to/
staging area though. Introduce `odb_transaction_env()` which is expected to provide the set of environment variables needed by a child process to access the transaction staging area.
Possessive s is missing, I think.
quoted hunk ↗ jump to hunk
diff --git a/object-file.c b/object-file.c index 696f05dc2d..14064d188a 100644 --- a/object-file.c +++ b/object-file.c@@ -1691,6 +1691,16 @@ static int odb_transaction_files_commit(struct odb_transaction *base) return 0; } +static const char **odb_transaction_files_env(struct odb_transaction *base) +{ + struct odb_transaction_files *transaction = + container_of(base, struct odb_transaction_files, base); + + odb_transaction_files_prepare(&transaction->base); + + return tmp_objdir_env(transaction->objdir); +} + int odb_transaction_files_begin(struct odb_source *source, struct odb_transaction **out) {
Makes sense. Transactions may have a different way to quarantine the write than using a quarantine directory. So making this functionality pluggable so that backends may expose a separate set of environment variables feels sensible.
quoted hunk ↗ jump to hunk
diff --git a/odb/transaction.h b/odb/transaction.h index 7898770071..536458297b 100644 --- a/odb/transaction.h +++ b/odb/transaction.h@@ -32,6 +32,16 @@ struct odb_transaction { int (*write_object_stream)(struct odb_transaction *transaction, struct odb_write_stream *stream, size_t len, struct object_id *oid); + + /* + * This callback is expected to return a NULL-terminated array of + * environment variables that a child process should inherit so + * that its object writes participate in the transaction. The + * returned array is owned by the backend and remains valid until + * the transaction ends. May return NULL when the backend does not + * need to expose any state to child processes. + */ + const char **(*env)(struct odb_transaction *transaction);
Would it make more sense to adapt this function so that:
- It receives a `struct strvec` as input that the environment
variables are to be amended to.
- It returns a normal error code to indicate errors?
Patrick