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

[RFC PATCH v2 2/2] Improve transport helper exec failure reporting

From
ILIlari Liusvaara <ilari.liusvaara@elisanet.fi>
Date
Jan 9, 2010, 13:45 UTC
Message-ID
<1263044757-12560-3-git-send-email-ilari.liusvaara@elisanet.fi>
In-Reply-To
<1263044757-12560-1-git-send-email-ilari.liusvaara@elisanet.fi>

Previously transport-helper exec failure error reporting was pretty much useless as it didn't report errors from execve, only from pipe and fork. Now that run-command passes errno from exec, use the improved support to actually print useful errors if execution fails.

Signed-off-by: Ilari Liusvaara <ilari.liusvaara@elisanet.fi>
---
 transport-helper.c |   27 +++++++++++++++++++++++----
 1 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/transport-helper.c b/transport-helper.c
index 5147296..72be965 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -102,6 +102,7 @@ static struct child_process *get_helper(struct transport *transport)
 	int refspec_nr = 0;
 	int refspec_alloc = 0;
 	int duped;
+	int code;
 
 	if (data->helper)
 		return data->helper;
@@ -111,13 +112,31 @@ static struct child_process *get_helper(struct transport *transport)
 	helper->out = -1;
 	helper->err = 0;
 	helper->argv = xcalloc(4, sizeof(*helper->argv));
-	strbuf_addf(&buf, "remote-%s", data->name);
+	strbuf_addf(&buf, "git-remote-%s", data->name);
 	helper->argv[0] = strbuf_detach(&buf, NULL);
 	helper->argv[1] = transport->remote->name;
 	helper->argv[2] = remove_ext_force(transport->url);
-	helper->git_cmd = 1;
-	if (start_command(helper))
-		die("Unable to run helper: git %s", helper->argv[0]);
+	helper->argv[2] = transport->url;
+	helper->git_cmd = 0;
+	helper->silent_exec_failure = 1;
+	helper->extended_error_code = 1;
+	/*
+	 * Print errors even if start_command should have printed them in
+	 * order to get proper fatal-level error message and include
+	 * errnos to make inevitable incomplete problem reports more useful
+	 * (those have nasty tendency of including only the last line that
+	 * looks like error).
+	 */
+	code = start_command(helper);
+	if (code == -2)
+		die("Unable to find remote helper for '%s'",
+			data->name);
+	else if(code == -1)
+		die_errno("Error running helper for '%s'", data->name);
+	else if(code != 0)
+		/* Shouldn't happen. */
+		die_errno("code %i running helper for '%s'", code, data->name);
+
 	data->helper = helper;
 	data->no_disconnect_req = 0;
 
-- 
1.6.6.3.gaa2e1
Previous: Johannes Sixt
Message 11 of 11 in “Imporove remote helper exec failure reporting”
  1. 0/2 Imporove remote helper exec failure reportingIlari Liusvaara, Jan 9, 2010
  2. 1/2 Report exec errors from run-commandIlari Liusvaara, Jan 9, 2010
  3. 0/4 Detect exec errors in start_command earlyJohannes Sixt, Jan 10, 2010
  4. 1/4 start_command: report child process setup errors to the parent's stderrJohannes Sixt, Jan 10, 2010
  5. 2/4 run-command: move wait_or_whine earlierJohannes Sixt, Jan 10, 2010
  6. 3/4 start_command: detect execvp failures earlyJohannes Sixt, Jan 10, 2010
  7. Junio C HamanoJan 14, 2010
  8. Johannes SixtJan 14, 2010
  9. Junio C HamanoJan 14, 2010
  10. 4/4 Improve error message when a transport helper was not foundJohannes Sixt, Jan 10, 2010
  11. 2/2 Improve transport helper exec failure reportingIlari Liusvaara, Jan 9, 2010

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.