git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 1/4] run-command: add repo_start_command()

From
Burak Kaan Karaçay <bkkaracay@gmail.com>
Date
Mar 11, 2026, 15:19 UTC
Message-ID
<20260311151923.4178655-2-bkkaracay@gmail.com>
In-Reply-To
<20260311151923.4178655-1-bkkaracay@gmail.com>

Currently start_command() relies on implicitly the_repository to close object store before the spawning a child process. This prevents callers from safely starting commands in context of a different repository.

Introduce repo_start_command() which takes 'struct repository *' as argument. To avoid breaking existing callers, redefine start_command() as a wrapper to pass the_repository to repo_start_command().

Signed-off-by: Burak Kaan Karaçay <bkkaracay@gmail.com>
---
 run-command.c | 7 ++++++-
 run-command.h | 4 +++-
 2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/run-command.c b/run-command.c
index b27064ef57..fadc3d5283 100644
--- a/run-command.c
+++ b/run-command.c
@@ -675,6 +675,11 @@ static void trace_run_command(const struct child_process *cp)
 }
 
 int start_command(struct child_process *cmd)
+{
+	return repo_start_command(the_repository, cmd);
+}
+
+int repo_start_command(struct repository *repo, struct child_process *cmd)
 {
 	int need_in, need_out, need_err;
 	int fdin[2], fdout[2], fderr[2];
@@ -743,7 +748,7 @@ int start_command(struct child_process *cmd)
 	fflush(NULL);
 
 	if (cmd->close_object_store)
-		odb_close(the_repository->objects);
+		odb_close(repo->objects);
 
 #ifndef GIT_WINDOWS_NATIVE
 {
diff --git a/run-command.h b/run-command.h
index e1ca965b5b..654ca659b3 100644
--- a/run-command.h
+++ b/run-command.h
@@ -2,7 +2,6 @@
 #define RUN_COMMAND_H
 
 #include "thread-utils.h"
-
 #include "strvec.h"
 
 /**
@@ -15,6 +14,7 @@
  * produces in the caller in order to process it.
  */
 
+struct repository;
 
 /**
  * This describes the arguments, redirections, and environment of a
@@ -205,7 +205,9 @@ char *git_shell_path(void);
  * that specifies the details and returns pipe FDs (if requested).
  * See below for details.
  */
+
 int start_command(struct child_process *);
+int repo_start_command(struct repository *, struct child_process *);
 
 /**
  * Wait for the completion of a sub-process that was started with
-- 
2.53.0
Previous: Burak Kaan KaraçayNext: Burak Kaan Karaçay
Message 2 of 18 in “wean start_command() off the_repository”
  1. 0/4 wean start_command() off the_repositoryBurak Kaan Karaçay, Mar 11, 2026
  2. 1/4 run-command: add repo_start_command()Burak Kaan Karaçay, Mar 11, 2026
  3. 2/4 run-command: use repo_start_command() in strict callersBurak Kaan Karaçay, Mar 11, 2026
  4. Junio C HamanoMar 11, 2026
  5. 3/4 run-command: redefine start_command() as a wrapper macroBurak Kaan Karaçay, Mar 11, 2026
  6. 4/4 cocci: convert start_command() to repo_start_command()Burak Kaan Karaçay, Mar 11, 2026
  7. René ScharfeMar 11, 2026
  8. Jeff KingMar 11, 2026
  9. Burak Kaan KaraçayMar 11, 2026
  10. Junio C HamanoMar 11, 2026
  11. Junio C HamanoMar 11, 2026
  12. run-command: wean start_command() off the_repositoryBurak Kaan Karaçay, Mar 12, 2026
  13. Patrick SteinhardtMar 12, 2026
  14. 0/2 run-command: stop using the_repositoryBurak Kaan Karaçay, Mar 12, 2026
  15. 1/2 run-command: wean start_command() off the_repositoryBurak Kaan Karaçay, Mar 12, 2026
  16. 2/2 run-command: wean auto_maintenance() functions off the_repositoryBurak Kaan Karaçay, Mar 12, 2026
  17. Junio C HamanoMar 12, 2026
  18. Patrick SteinhardtMar 13, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.