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

[PATCH v2 4/4] run-command: inline prepare_run_command_v_opt()

From
René Scharfe <l.s.r@web.de>
Date
Aug 19, 2014, 19:11 UTC
Message-ID
<53F3A16F.10303@web.de>
In-Reply-To
<xmqq61hpybs9.fsf@gitster.dls.corp.google.com>

Merge prepare_run_command_v_opt() and its only caller. This removes a pointer indirection and allows to initialize the struct child_process using CHILD_PROCESS_INIT.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
---
 run-command.c | 24 ++++++++----------------
 1 file changed, 8 insertions(+), 16 deletions(-)
diff --git a/run-command.c b/run-command.c
index 9196ee0..761f0fd 100644
--- a/run-command.c
+++ b/run-command.c
@@ -561,20 +561,6 @@ int run_command(struct child_process *cmd)
 	return finish_command(cmd);
 }
 
-static void prepare_run_command_v_opt(struct child_process *cmd,
-				      const char **argv,
-				      int opt)
-{
-	memset(cmd, 0, sizeof(*cmd));
-	cmd->argv = argv;
-	cmd->no_stdin = opt & RUN_COMMAND_NO_STDIN ? 1 : 0;
-	cmd->git_cmd = opt & RUN_GIT_CMD ? 1 : 0;
-	cmd->stdout_to_stderr = opt & RUN_COMMAND_STDOUT_TO_STDERR ? 1 : 0;
-	cmd->silent_exec_failure = opt & RUN_SILENT_EXEC_FAILURE ? 1 : 0;
-	cmd->use_shell = opt & RUN_USING_SHELL ? 1 : 0;
-	cmd->clean_on_exit = opt & RUN_CLEAN_ON_EXIT ? 1 : 0;
-}
-
 int run_command_v_opt(const char **argv, int opt)
 {
 	return run_command_v_opt_cd_env(argv, opt, NULL, NULL);
@@ -582,8 +568,14 @@ int run_command_v_opt(const char **argv, int opt)
 
 int run_command_v_opt_cd_env(const char **argv, int opt, const char *dir, const char *const *env)
 {
-	struct child_process cmd;
-	prepare_run_command_v_opt(&cmd, argv, opt);
+	struct child_process cmd = CHILD_PROCESS_INIT;
+	cmd.argv = argv;
+	cmd.no_stdin = opt & RUN_COMMAND_NO_STDIN ? 1 : 0;
+	cmd.git_cmd = opt & RUN_GIT_CMD ? 1 : 0;
+	cmd.stdout_to_stderr = opt & RUN_COMMAND_STDOUT_TO_STDERR ? 1 : 0;
+	cmd.silent_exec_failure = opt & RUN_SILENT_EXEC_FAILURE ? 1 : 0;
+	cmd.use_shell = opt & RUN_USING_SHELL ? 1 : 0;
+	cmd.clean_on_exit = opt & RUN_CLEAN_ON_EXIT ? 1 : 0;
 	cmd.dir = dir;
 	cmd.env = env;
 	return run_command(&cmd);
-- 
2.1.0
Previous: René Scharfe
Message 11 of 11 in “run-command: introduce CHILD_PROCESS_INIT”
  1. run-command: introduce CHILD_PROCESS_INITRené Scharfe, Aug 16, 2014
  2. Jeff KingAug 17, 2014
  3. René ScharfeAug 17, 2014
  4. Jeff KingAug 17, 2014
  5. Johannes SixtAug 17, 2014
  6. Jeff KingAug 17, 2014
  7. Junio C HamanoAug 18, 2014
  8. 1/4 run-command: introduce CHILD_PROCESS_INITRené Scharfe, Aug 19, 2014
  9. 2/4 run-command: introduce child_process_init()René Scharfe, Aug 19, 2014
  10. 3/4 run-command: call run_command_v_opt_cd_env() instead of duplicating itRené Scharfe, Aug 19, 2014
  11. 4/4 run-command: inline prepare_run_command_v_opt()René Scharfe, Aug 19, 2014

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.