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

[PATCH 1/3] remote-curl: do not complain on EOF from parent git

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

The parent git process is supposed to send us an empty line to indicate that the conversation is over. However, the parent process may die() if there is a problem with the operation (e.g., we try to fetch a ref that does not exist). In this case, it produces a useful message, but then remote-curl _also_ produces an unhelpful message:

  $ git pull origin matser
  fatal: couldn't find remote ref matser
  Unexpected end of command stream

The "right" way to fix this is to teach the parent git to always cleanly close the connection to the helper, letting it know that we are done. Implementing that is rather clunky, though, as it would involve either replacing die() operations with returning errors up the stack (until we disconnect the transport), or adding an atexit handler to clean up any transport helpers left open.

It's much simpler to just suppress the EOF message in remote-curl. It was not added to address any real-world situation in the first place, but rather a "we should probably report unexpected things" suggestion[1].

It is the parent git which drives the operation, and whose exit value actually matters. If the parent dies, then the helper has no need to complain (except as a debugging aid). In the off chance that the pipe is closed without the parent dying, it can still notice the non-zero exit code.

[1] http://article.gmane.org/gmane.comp.version-control.git/176036
Signed-off-by: Jeff King <peff@peff.net>
---
Repost fixing commit message typo (and indicating it as the first of 3
patches).
 remote-curl.c | 2 --
 1 file changed, 2 deletions(-)
diff --git a/remote-curl.c b/remote-curl.c
index 4493b38..0454ffc 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -971,8 +971,6 @@ int main(int argc, const char **argv)
 		if (strbuf_getline(&buf, stdin, '\n') == EOF) {
 			if (ferror(stdin))
 				fprintf(stderr, "Error reading command stream\n");
-			else
-				fprintf(stderr, "Unexpected end of command stream\n");
 			return 1;
 		}
 		if (buf.len == 0)
-- 
2.0.0.566.gfe3e6b2
Previous: Jeff KingNext: Jeff King
Message 6 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.