From: "Burak Kaan Karaçay" <bkkaracay@gmail.com>
To: git@vger.kernel.org
Cc: christian.couder@gmail.com, karthik.188@gmail.com,
jltobler@gmail.com, ayu.chandekar@gmail.com,
siddharthasthana31@gmail.com, l.s.r@web.de, ps@pks.im,
peff@peff.net, gitster@pobox.com,
"Burak Kaan Karaçay" <bkkaracay@gmail.com>
Subject: [PATCH v3 1/2] run-command: wean start_command() off the_repository
Date: Thu, 12 Mar 2026 17:44:36 +0300 [thread overview]
Message-ID: <20260312144437.626392-2-bkkaracay@gmail.com> (raw)
In-Reply-To: <20260312144437.626392-1-bkkaracay@gmail.com>
The start_command() relies on the_repository due to the
close_object_store flag in 'struct child_process'. When this flag is
set, start_command() closes the object store associated with
the_repository before spawning a child process.
To eliminate this dependency, replace the 'close_object_store' with the
new 'struct object_database *odb_to_close' field. This allows callers to
specify the object store that needs to be closed.
Suggested-by: René Scharfe <l.s.r@web.de>
Signed-off-by: Burak Kaan Karaçay <bkkaracay@gmail.com>
---
builtin/gc.c | 14 +++++++++-----
builtin/pull.c | 2 +-
run-command.c | 6 +++---
run-command.h | 2 +-
4 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/builtin/gc.c b/builtin/gc.c
index fb329c2cff..5d8d358f7a 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -1030,7 +1030,7 @@ int cmd_gc(int argc,
struct child_process repack_cmd = CHILD_PROCESS_INIT;
repack_cmd.git_cmd = 1;
- repack_cmd.close_object_store = 1;
+ repack_cmd.odb_to_close = the_repository->objects;
strvec_pushv(&repack_cmd.args, repack_args.v);
if (run_command(&repack_cmd))
die(FAILED_RUN, repack_args.v[0]);
@@ -1199,7 +1199,8 @@ static int run_write_commit_graph(struct maintenance_run_opts *opts)
{
struct child_process child = CHILD_PROCESS_INIT;
- child.git_cmd = child.close_object_store = 1;
+ child.git_cmd = 1;
+ child.odb_to_close = the_repository->objects;
strvec_pushl(&child.args, "commit-graph", "write",
"--split", "--reachable", NULL);
@@ -1268,7 +1269,8 @@ static int maintenance_task_gc_background(struct maintenance_run_opts *opts,
{
struct child_process child = CHILD_PROCESS_INIT;
- child.git_cmd = child.close_object_store = 1;
+ child.git_cmd = 1;
+ child.odb_to_close = the_repository->objects;
strvec_push(&child.args, "gc");
if (opts->auto_flag)
@@ -1484,7 +1486,8 @@ static int multi_pack_index_expire(struct maintenance_run_opts *opts)
{
struct child_process child = CHILD_PROCESS_INIT;
- child.git_cmd = child.close_object_store = 1;
+ child.git_cmd = 1;
+ child.odb_to_close = the_repository->objects;
strvec_pushl(&child.args, "multi-pack-index", "expire", NULL);
if (opts->quiet)
@@ -1542,7 +1545,8 @@ static int multi_pack_index_repack(struct maintenance_run_opts *opts)
{
struct child_process child = CHILD_PROCESS_INIT;
- child.git_cmd = child.close_object_store = 1;
+ child.git_cmd = 1;
+ child.odb_to_close = the_repository->objects;
strvec_pushl(&child.args, "multi-pack-index", "repack", NULL);
if (opts->quiet)
diff --git a/builtin/pull.c b/builtin/pull.c
index 6ad420ce6f..7e67fdce97 100644
--- a/builtin/pull.c
+++ b/builtin/pull.c
@@ -454,7 +454,7 @@ static int run_fetch(const char *repo, const char **refspecs)
} else if (*refspecs)
BUG("refspecs without repo?");
cmd.git_cmd = 1;
- cmd.close_object_store = 1;
+ cmd.odb_to_close = the_repository->objects;
return run_command(&cmd);
}
diff --git a/run-command.c b/run-command.c
index b27064ef57..ed5e8be976 100644
--- a/run-command.c
+++ b/run-command.c
@@ -742,8 +742,8 @@ int start_command(struct child_process *cmd)
fflush(NULL);
- if (cmd->close_object_store)
- odb_close(the_repository->objects);
+ if (cmd->odb_to_close)
+ odb_close(cmd->odb_to_close);
#ifndef GIT_WINDOWS_NATIVE
{
@@ -1955,7 +1955,7 @@ int prepare_auto_maintenance(int quiet, struct child_process *maint)
auto_detach = git_env_bool("GIT_TEST_MAINT_AUTO_DETACH", true);
maint->git_cmd = 1;
- maint->close_object_store = 1;
+ maint->odb_to_close = the_repository->objects;
strvec_pushl(&maint->args, "maintenance", "run", "--auto", NULL);
strvec_push(&maint->args, quiet ? "--quiet" : "--no-quiet");
strvec_push(&maint->args, auto_detach ? "--detach" : "--no-detach");
diff --git a/run-command.h b/run-command.h
index e1ca965b5b..af4c9da279 100644
--- a/run-command.h
+++ b/run-command.h
@@ -136,7 +136,7 @@ struct child_process {
* want to repack because that would delete `.pack` files (and on
* Windows, you cannot delete files that are still in use).
*/
- unsigned close_object_store:1;
+ struct object_database *odb_to_close;
unsigned stdout_to_stderr:1;
unsigned clean_on_exit:1;
--
2.53.0
next prev parent reply other threads:[~2026-03-12 14:44 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-11 15:19 [PATCH 0/4] wean start_command() off the_repository Burak Kaan Karaçay
2026-03-11 15:19 ` [PATCH 1/4] run-command: add repo_start_command() Burak Kaan Karaçay
2026-03-11 15:19 ` [PATCH 2/4] run-command: use repo_start_command() in strict callers Burak Kaan Karaçay
2026-03-11 19:26 ` Junio C Hamano
2026-03-11 15:19 ` [PATCH 3/4] run-command: redefine start_command() as a wrapper macro Burak Kaan Karaçay
2026-03-11 15:19 ` [PATCH 4/4] cocci: convert start_command() to repo_start_command() Burak Kaan Karaçay
2026-03-11 18:18 ` [PATCH 0/4] wean start_command() off the_repository René Scharfe
2026-03-11 18:45 ` Jeff King
2026-03-11 19:09 ` Burak Kaan Karaçay
2026-03-11 19:35 ` Junio C Hamano
2026-03-11 19:30 ` Junio C Hamano
2026-03-12 8:53 ` [PATCH v2] run-command: " Burak Kaan Karaçay
2026-03-12 10:01 ` Patrick Steinhardt
2026-03-12 14:44 ` [PATCH v3 0/2] run-command: stop using the_repository Burak Kaan Karaçay
2026-03-12 14:44 ` Burak Kaan Karaçay [this message]
2026-03-12 14:44 ` [PATCH v3 2/2] run-command: wean auto_maintenance() functions off the_repository Burak Kaan Karaçay
2026-03-12 15:29 ` [PATCH v3 0/2] run-command: stop using the_repository Junio C Hamano
2026-03-13 6:23 ` 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=20260312144437.626392-2-bkkaracay@gmail.com \
--to=bkkaracay@gmail.com \
--cc=ayu.chandekar@gmail.com \
--cc=christian.couder@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=jltobler@gmail.com \
--cc=karthik.188@gmail.com \
--cc=l.s.r@web.de \
--cc=peff@peff.net \
--cc=ps@pks.im \
--cc=siddharthasthana31@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