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

[PATCH 3/3] remote-curl: mark helper-protocol errors more clearly

From
Jeff King <peff@peff.net>
Date
Jul 9, 2014, 21:47 UTC
Message-ID
<20140709214720.GC26999@sigill.intra.peff.net>
In-Reply-To
<20140709212043.GC25854@sigill.intra.peff.net>

When we encounter an error in remote-curl, we generally just report it to stderr. There is no need for the user to care that the "could not connect to server" error was generated by git-remote-https rather than a function in the parent git-fetch process.

However, when the error is in the protocol between git and the helper, it makes sense to clearly identify which side is complaining. These cases shouldn't ever happen, but when they do, we can make them less confusing by being more verbose.

Signed-off-by: Jeff King <peff@peff.net>
---
 remote-curl.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/remote-curl.c b/remote-curl.c
index a619b64..1f6905d 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -949,7 +949,7 @@ int main(int argc, const char **argv)
 	git_extract_argv0_path(argv[0]);
 	setup_git_directory_gently(&nongit);
 	if (argc < 2) {
-		error("remote needed");
+		error("remote-curl: usage: git remote-curl <remote> [<url>]");
 		return 1;
 	}
 
@@ -970,14 +970,14 @@ int main(int argc, const char **argv)
 	do {
 		if (strbuf_getline(&buf, stdin, '\n') == EOF) {
 			if (ferror(stdin))
-				error("error reading command stream");
+				error("remote-curl: error reading command stream from git");
 			return 1;
 		}
 		if (buf.len == 0)
 			break;
 		if (starts_with(buf.buf, "fetch ")) {
 			if (nongit)
-				die("Fetch attempted without a local repo");
+				die("remote-curl: fetch attempted without a local repo");
 			parse_fetch(&buf);
 
 		} else if (!strcmp(buf.buf, "list") || starts_with(buf.buf, "list ")) {
@@ -1014,7 +1014,7 @@ int main(int argc, const char **argv)
 			printf("\n");
 			fflush(stdout);
 		} else {
-			error("unknown command '%s'", buf.buf);
+			error("remote-curl: unknown command '%s' from git", buf.buf);
 			return 1;
 		}
 		strbuf_reset(&buf);
-- 
2.0.0.566.gfe3e6b2
Previous: Jeff King
Message 8 of 8 in “"Unexpected end of command stream" message looks irrelevant when I try to pull a non-existing branch”
  1. DmitryJul 9, 2014
  2. Jeff KingJul 9, 2014
  3. remote-curl: do not complain on EOF from parent gitJeff King, Jul 9, 2014
  4. Keller, Jacob EJul 9, 2014
  5. Jeff KingJul 9, 2014
  6. 1/3 remote-curl: do not complain on EOF from parent gitJeff King, Jul 9, 2014
  7. 2/3 remote-curl: use error instead of fprintf(stderr)Jeff King, Jul 9, 2014
  8. 3/3 remote-curl: mark helper-protocol errors more clearlyJeff King, Jul 9, 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.