git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] remote-curl: Fix push status report when all branches fail
@ 2012-01-19 22:24 Shawn O. Pearce
  2012-01-19 22:57 ` Junio C Hamano
  0 siblings, 1 reply; 14+ messages in thread
From: Shawn O. Pearce @ 2012-01-19 22:24 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Shawn O. Pearce

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

^ permalink raw reply related	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2012-02-23 19:12 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-19 22:24 [PATCH] remote-curl: Fix push status report when all branches fail Shawn O. Pearce
2012-01-19 22:57 ` Junio C Hamano
2012-01-20  3:12   ` Shawn O. Pearce
2012-01-20  5:49     ` Junio C Hamano
2012-01-20  6:00     ` Junio C Hamano
2012-01-20 15:15       ` Shawn Pearce
2012-01-20 16:17         ` Thomas Rast
2012-01-20 17:03           ` Shawn O. Pearce
2012-01-20 18:18             ` Junio C Hamano
2012-02-22 10:13             ` Jeff King
2012-02-22 15:22               ` Shawn Pearce
2012-02-22 20:40                 ` Jeff King
2012-02-23 10:04                   ` Jeff King
2012-02-23 19:11                     ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).