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

[PATCH 5/7] Use run_command within merge-index

From
Shawn O. Pearce <spearce@spearce.org>
Date
Mar 12, 2007, 23:00 UTC
Message-ID
<20070312230021.GE16840@spearce.org>

Maybe unnecessary as the merge-index utility may go away in the future, but its currently here, its shorter to use run_command, and probably will help the MinGW port out.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 merge-index.c |   23 +++++------------------
 1 files changed, 5 insertions(+), 18 deletions(-)
diff --git a/merge-index.c b/merge-index.c
index 7027d78..6df4394 100644
--- a/merge-index.c
+++ b/merge-index.c
@@ -1,4 +1,5 @@
 #include "cache.h"
+#include "run-command.h"
 
 static const char *pgm;
 static const char *arguments[8];
@@ -7,24 +8,10 @@ static int err;
 
 static void run_program(void)
 {
-	pid_t pid = fork();
-	int status;
-
-	if (pid < 0)
-		die("unable to fork");
-	if (!pid) {
-		execlp(pgm, arguments[0],
-			    arguments[1],
-			    arguments[2],
-			    arguments[3],
-			    arguments[4],
-			    arguments[5],
-			    arguments[6],
-			    arguments[7],
-			    NULL);
-		die("unable to execute '%s'", pgm);
-	}
-	if (waitpid(pid, &status, 0) < 0 || !WIFEXITED(status) || WEXITSTATUS(status)) {
+	struct child_process child;
+	memset(&child, 0, sizeof(child));
+	child.argv = arguments;
+	if (run_command(&child)) {
 		if (one_shot) {
 			err++;
 		} else {
-- 
1.5.0.3.985.gcf0b4
Message 1 of 1 in “Use run_command within merge-index”
  1. 5/7 Use run_command within merge-indexShawn O. Pearce, Mar 12, 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.