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

[PATCH v5] transport-helper: report errors properly

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Apr 11, 2013, 17:47 UTC
Message-ID
<1365702434-24704-1-git-send-email-felipe.contreras@gmail.com>

If a push fails because the remote-helper died (with fast-export), the user might not see any error message. So let's add one.

Suggested-by: Jeff King <peff@peff.net>
Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 git-remote-testgit        | 11 +++++++++++
 t/t5801-remote-helpers.sh | 10 ++++++++++
 transport-helper.c        |  2 +-
 3 files changed, 22 insertions(+), 1 deletion(-)
diff --git a/git-remote-testgit b/git-remote-testgit
index b395c8d..472ab1a 100755
--- a/git-remote-testgit
+++ b/git-remote-testgit
@@ -67,6 +67,17 @@ do
 		echo "done"
 		;;
 	export)
+		if test -n "$GIT_REMOTE_TESTGIT_FAILURE"
+		then
+			# consume input so fast-export doesn't get SIGPIPE; we
+			# want to test the remote-helper's code after
+			# fast-export.
+			while read line; do
+				test "done" = "$line" && break
+			done
+			exit 1
+		fi
+
 		before=$(git for-each-ref --format='%(refname) %(objectname)')
 
 		git fast-import "${testgitmarks_args[@]}" --quiet
diff --git a/t/t5801-remote-helpers.sh b/t/t5801-remote-helpers.sh
index f387027..8d61702 100755
--- a/t/t5801-remote-helpers.sh
+++ b/t/t5801-remote-helpers.sh
@@ -166,4 +166,14 @@ test_expect_success 'push ref with existing object' '
 	compare_refs local dup server dup
 '
 
+test_expect_success 'proper failure checks for pushing' '
+	(GIT_REMOTE_TESTGIT_FAILURE=1 &&
+	export GIT_REMOTE_TESTGIT_FAILURE &&
+	cd local &&
+	test_must_fail git push --all 2> error &&
+	cat error &&
+	grep -q "Reading from remote helper failed" error
+	)
+'
+
 test_done
diff --git a/transport-helper.c b/transport-helper.c
index cb3ef7d..96081cc 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -54,7 +54,7 @@ static int recvline_fh(FILE *helper, struct strbuf *buffer)
 	if (strbuf_getline(buffer, helper, '\n') == EOF) {
 		if (debug)
 			fprintf(stderr, "Debug: Remote helper quit.\n");
-		exit(128);
+		die("Reading from remote helper failed");
 	}
 
 	if (debug)
-- 
1.8.2.1
Message 1 of 1 in “transport-helper: report errors properly”
  1. transport-helper: report errors properlyFelipe Contreras, Apr 11, 2013

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.