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

[PATCH] remote-curl: Fix push status report when all branches fail

From
Shawn O. Pearce <spearce@spearce.org>
Date
Jan 19, 2012, 22:24 UTC
Message-ID
<1327011899-18883-1-git-send-email-spearce@spearce.org>
From: "Shawn O. Pearce" <spearce@spearce.org>

The protocol between transport-helper.c and remote-curl requires remote-curl to always print a blank line after the push command has run. If the blank line is ommitted, transport-helper kills its container process (the git push the user started) with exit(128) and no message indicating a problem, assuming the helper already printed reasonable error text to the console.

However if the remote rejects all branches with "ng" commands in the report-status reply, send-pack terminates with non-zero status, and in turn remote-curl exited with non-zero status before outputting the blank line after the helper status printed by send-pack. No error messages reach the user.

This caused users to see the following from git push over HTTP when the remote side's update hook rejected the branch:

  $ git push http://... master
  Counting objects: 4, done.
  Delta compression using up to 6 threads.
  Compressing objects: 100% (2/2), done.
  Writing objects: 100% (3/3), 301 bytes, done.
  Total 3 (delta 0), reused 0 (delta 0)
  $

Always print a blank line after the send-pack process terminates, ensuring the helper status report (if it was output) will be correctly parsed by the calling transport-helper.c. This ensures the helper doesn't abort before the status report can be shown to the user.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 remote-curl.c |    9 ++++-----
 1 files changed, 4 insertions(+), 5 deletions(-)
diff --git a/remote-curl.c b/remote-curl.c
index 48c20b8..d6054e2 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -805,7 +805,7 @@ static int push(int nr_spec, char **specs)
 static void parse_push(struct strbuf *buf)
 {
 	char **specs = NULL;
-	int alloc_spec = 0, nr_spec = 0, i;
+	int alloc_spec = 0, nr_spec = 0, i, ret;
 
 	do {
 		if (!prefixcmp(buf->buf, "push ")) {
@@ -822,12 +822,11 @@ static void parse_push(struct strbuf *buf)
 			break;
 	} while (1);
 
-	if (push(nr_spec, specs))
+	ret = push(nr_spec, specs);
+	xwrite(1, "\n", 1);
+	if (ret)
 		exit(128); /* error already reported */
 
-	printf("\n");
-	fflush(stdout);
-
  free_specs:
 	for (i = 0; i < nr_spec; i++)
 		free(specs[i]);
-- 
1.7.8.4.dirty
Next: Junio C Hamano
Message 1 of 14 in “remote-curl: Fix push status report when all branches fail”
  1. remote-curl: Fix push status report when all branches failShawn O. Pearce, Jan 19, 2012
  2. Junio C HamanoJan 19, 2012
  3. remote-curl: Fix push status report when all branches failShawn O. Pearce, Jan 20, 2012
  4. Junio C HamanoJan 20, 2012
  5. Junio C HamanoJan 20, 2012
  6. Shawn PearceJan 20, 2012
  7. Thomas RastJan 20, 2012
  8. remote-curl: Fix push status report when all branches failShawn O. Pearce, Jan 20, 2012
  9. Junio C HamanoJan 20, 2012
  10. Jeff KingFeb 22, 2012
  11. Shawn PearceFeb 22, 2012
  12. Jeff KingFeb 22, 2012
  13. Jeff KingFeb 23, 2012
  14. Junio C HamanoFeb 23, 2012

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.