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

[PATCH 3/4] run-command: redefine start_command() as a wrapper macro

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

In the commit introducing 'repo_start_command()', 'start_command()' was redefined as a wrapper function.

Now, redefine 'start_command()' as a wrapper macro to make 'the_repository' dependency explicit at the caller's site. To successfully build, expose 'the_repository' dependency at the call sites by defining 'USE_THE_REPOSITORY_VARIABLE' or including 'repository.h' where necessary.

Signed-off-by: Burak Kaan Karaçay <bkkaracay@gmail.com>
---
 builtin/credential-cache.c  | 2 ++
 builtin/remote-ext.c        | 2 ++
 column.c                    | 1 +
 credential.c                | 1 +
 midx-write.c                | 2 ++
 prompt.c                    | 1 +
 repack-cruft.c              | 2 ++
 repack-filtered.c           | 2 ++
 repack-midx.c               | 2 ++
 repack-promisor.c           | 2 ++
 run-command.c               | 5 -----
 run-command.h               | 2 +-
 sub-process.c               | 3 +++
 t/helper/test-run-command.c | 2 ++
 14 files changed, 23 insertions(+), 6 deletions(-)
diff --git a/builtin/credential-cache.c b/builtin/credential-cache.c
index 7f733cb756..fb17aa87ba 100644
--- a/builtin/credential-cache.c
+++ b/builtin/credential-cache.c
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "builtin.h"
 #include "credential.h"
 #include "gettext.h"
diff --git a/builtin/remote-ext.c b/builtin/remote-ext.c
index bd2037f27d..ed2d551753 100644
--- a/builtin/remote-ext.c
+++ b/builtin/remote-ext.c
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "builtin.h"
 #include "transport.h"
 #include "run-command.h"
diff --git a/column.c b/column.c
index 93fae316b4..998b2ab458 100644
--- a/column.c
+++ b/column.c
@@ -1,3 +1,4 @@
+#define USE_THE_REPOSITORY_VARIABLE
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
diff --git a/credential.c b/credential.c
index 2594c0c422..a513355105 100644
--- a/credential.c
+++ b/credential.c
@@ -1,3 +1,4 @@
+#define USE_THE_REPOSITORY_VARIABLE
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "git-compat-util.h"
diff --git a/midx-write.c b/midx-write.c
index 6485cb6706..a53f77f13a 100644
--- a/midx-write.c
+++ b/midx-write.c
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "abspath.h"
 #include "config.h"
diff --git a/prompt.c b/prompt.c
index 706fba2a50..20a8c34438 100644
--- a/prompt.c
+++ b/prompt.c
@@ -7,6 +7,7 @@
 #include "strbuf.h"
 #include "prompt.h"
 #include "compat/terminal.h"
+#include "repository.h"
 
 static char *do_askpass(const char *cmd, const char *prompt)
 {
diff --git a/repack-cruft.c b/repack-cruft.c
index 0653e88792..0bfc77792a 100644
--- a/repack-cruft.c
+++ b/repack-cruft.c
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "repack.h"
 #include "packfile.h"
diff --git a/repack-filtered.c b/repack-filtered.c
index edcf7667c5..2f5d1dd709 100644
--- a/repack-filtered.c
+++ b/repack-filtered.c
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "repack.h"
 #include "repository.h"
diff --git a/repack-midx.c b/repack-midx.c
index 0682b80c42..8b4c0d95e3 100644
--- a/repack-midx.c
+++ b/repack-midx.c
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "repack.h"
 #include "hash.h"
diff --git a/repack-promisor.c b/repack-promisor.c
index dba161a11a..70ef19d04f 100644
--- a/repack-promisor.c
+++ b/repack-promisor.c
@@ -1,3 +1,5 @@
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "repack.h"
 #include "hex.h"
diff --git a/run-command.c b/run-command.c
index fadc3d5283..af26c636a9 100644
--- a/run-command.c
+++ b/run-command.c
@@ -674,11 +674,6 @@ static void trace_run_command(const struct child_process *cp)
 	strbuf_release(&buf);
 }
 
-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;
diff --git a/run-command.h b/run-command.h
index 654ca659b3..890d7c5d72 100644
--- a/run-command.h
+++ b/run-command.h
@@ -206,7 +206,7 @@ char *git_shell_path(void);
  * See below for details.
  */
 
-int start_command(struct child_process *);
+#define start_command(cmd) repo_start_command(the_repository, cmd)
 int repo_start_command(struct repository *, struct child_process *);
 
 /**
diff --git a/sub-process.c b/sub-process.c
index 83bf0a0e82..ae7493eb5c 100644
--- a/sub-process.c
+++ b/sub-process.c
@@ -1,10 +1,13 @@
 /*
  * Generic implementation of background process infrastructure.
  */
+#define USE_THE_REPOSITORY_VARIABLE
+
 #include "git-compat-util.h"
 #include "sub-process.h"
 #include "sigchain.h"
 #include "pkt-line.h"
+#include "repository.h"
 
 int cmd2process_cmp(const void *cmp_data UNUSED,
 		    const struct hashmap_entry *eptr,
diff --git a/t/helper/test-run-command.c b/t/helper/test-run-command.c
index 4a56456894..dcd58f228c 100644
--- a/t/helper/test-run-command.c
+++ b/t/helper/test-run-command.c
@@ -8,6 +8,7 @@
  * published by the Free Software Foundation.
  */
 
+#define USE_THE_REPOSITORY_VARIABLE
 #define DISABLE_SIGN_COMPARE_WARNINGS
 
 #include "test-tool.h"
@@ -18,6 +19,7 @@
 #include "string-list.h"
 #include "thread-utils.h"
 #include "wildmatch.h"
+#include "repository.h"
 
 static int number_callbacks;
 static int parallel_next(struct child_process *cp,
-- 
2.53.0
Previous: Junio C HamanoNext: Burak Kaan Karaçay
Message 5 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.