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

[PATCH] allow commands to be executed in submodules

From
Martin Waitz <tali@admingilde.org>
Date
May 20, 2007, 15:39 UTC
Message-ID
<20070520153908.GF5412@admingilde.org>

Add an extra "submodule" field to struct child_process to be able to easily start commands which are to be executed in a submodule repository.

Signed-off-by: Martin Waitz <tali@admingilde.org>
---
 run-command.c     |   13 ++++++
 run-command.h     |    1 +
 2 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/run-command.c b/run-command.c
index eff523e..c2475e4 100644
--- a/run-command.c
+++ b/run-command.c
@@ -73,6 +73,19 @@ int start_command(struct child_process *cmd)
 			close(cmd->out);
 		}
 
+		if (cmd->submodule) {
+			int err = chdir(cmd->submodule);
+			if (err) {
+				die("cannot exec %s in %s.",
+					cmd->argv[0], cmd->submodule);
+			}
+			/* don't inherit supermodule environment */
+			unsetenv(GIT_DIR_ENVIRONMENT);
+			unsetenv(DB_ENVIRONMENT);
+			unsetenv(INDEX_ENVIRONMENT);
+			unsetenv(GRAFT_ENVIRONMENT);
+		}
+
 		if (cmd->git_cmd) {
 			execv_git_cmd(cmd->argv);
 		} else {
diff --git a/run-command.h b/run-command.h
index 3680ef9..2940186 100644
--- a/run-command.h
+++ b/run-command.h
@@ -16,6 +16,7 @@ struct child_process {
 	pid_t pid;
 	int in;
 	int out;
+	const char *submodule;
 	unsigned close_in:1;
 	unsigned close_out:1;
 	unsigned no_stdin:1;
-- 
1.5.2.2.g081e


-- 
Martin Waitz
Next: Alex Riesen
Message 1 of 20 in “allow commands to be executed in submodules”
  1. allow commands to be executed in submodulesMartin Waitz, May 20, 2007
  2. Alex RiesenMay 20, 2007
  3. Junio C HamanoMay 20, 2007
  4. Martin WaitzMay 20, 2007
  5. Alex RiesenMay 20, 2007
  6. Martin WaitzMay 20, 2007
  7. Add ability to specify environment extension to run_commandAlex Riesen, May 21, 2007
  8. Junio C HamanoMay 21, 2007
  9. Martin WaitzMay 22, 2007
  10. Junio C HamanoMay 22, 2007
  11. Shawn O. PearceMay 22, 2007
  12. Sven VerdoolaegeMay 22, 2007
  13. Alex RiesenMay 22, 2007
  14. Alex RiesenMay 22, 2007
  15. Add run_command_v_opt_cd: chdir into a directory before execAlex Riesen, May 22, 2007
  16. Add ability to specify environment extension to run_commandAlex Riesen, May 22, 2007
  17. Allow environment variables to be unset in the processes started by run_commandAlex Riesen, May 22, 2007
  18. Junio C HamanoMay 22, 2007
  19. Alex RiesenMay 22, 2007
  20. Allow environment variables to be unset in the processes started by run_commandAlex Riesen, May 23, 2007

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.