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

[PATCH 3/5] transport-helper: propagate recvline() error pushing

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 19, 2014, 07:00 UTC
Message-ID
<1397890843-27035-4-git-send-email-gitster@pobox.com>
In-Reply-To
<1397890843-27035-1-git-send-email-gitster@pobox.com>
From: Felipe Contreras <felipe.contreras@gmail.com>

It's cleaner, and will allow us to do something sensible on errors later.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 transport-helper.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/transport-helper.c b/transport-helper.c
index f0d7fc7..e91bc9a 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -739,17 +739,22 @@ static int push_update_ref_status(struct strbuf *buf,
 	return !(status == REF_STATUS_OK);
 }
 
-static void push_update_refs_status(struct helper_data *data,
+static int push_update_refs_status(struct helper_data *data,
 				    struct ref *remote_refs,
 				    int flags)
 {
 	struct strbuf buf = STRBUF_INIT;
 	struct ref *ref = remote_refs;
+	int ret = 0;
+
 	for (;;) {
 		char *private;
 
-		if (recvline(data, &buf))
-			exit(128);
+		if (recvline(data, &buf)) {
+			ret = 1;
+			break;
+		}
+
 		if (!buf.len)
 			break;
 
@@ -767,6 +772,7 @@ static void push_update_refs_status(struct helper_data *data,
 		free(private);
 	}
 	strbuf_release(&buf);
+	return ret;
 }
 
 static int push_refs_with_push(struct transport *transport,
@@ -847,8 +853,7 @@ static int push_refs_with_push(struct transport *transport,
 	sendline(data, &buf);
 	strbuf_release(&buf);
 
-	push_update_refs_status(data, remote_refs, flags);
-	return 0;
+	return push_update_refs_status(data, remote_refs, flags);
 }
 
 static int push_refs_with_export(struct transport *transport,
@@ -906,8 +911,7 @@ static int push_refs_with_export(struct transport *transport,
 
 	if (finish_command(&exporter))
 		die("Error while running fast-export");
-	push_update_refs_status(data, remote_refs, flags);
-	return 0;
+	return push_update_refs_status(data, remote_refs, flags);
 }
 
 static int push_refs(struct transport *transport,
-- 
1.9.2-459-g68773ac
Previous: Junio C HamanoNext: Junio C Hamano
Message 13 of 20 in “transport-helper: serious crash fix”
  1. 0/5 transport-helper: serious crash fixFelipe Contreras, Apr 12, 2014
  2. 1/5 transport-helper: remove barely used xchgline()Felipe Contreras, Apr 12, 2014
  3. 2/5 remote-helpers: make recvline return an errorFelipe Contreras, Apr 12, 2014
  4. 3/5 transport-helper: propagate recvline() error pushingFelipe Contreras, Apr 12, 2014
  5. 4/5 transport-helper: trivial cleanupFelipe Contreras, Apr 12, 2014
  6. Junio C HamanoApr 14, 2014
  7. 5/5 transport-helper: fix sync issue on crashesFelipe Contreras, Apr 12, 2014
  8. Junio C HamanoApr 14, 2014
  9. Junio C HamanoApr 15, 2014
  10. 0/5 fc/transport-helper-sync-error-fix rebasedJunio C Hamano, Apr 19, 2014
  11. 1/5 transport-helper: remove barely used xchgline()Junio C Hamano, Apr 19, 2014
  12. 2/5 remote-helpers: make recvline return an errorJunio C Hamano, Apr 19, 2014
  13. 3/5 transport-helper: propagate recvline() error pushingJunio C Hamano, Apr 19, 2014
  14. 4/5 transport-helper: trivial cleanupJunio C Hamano, Apr 19, 2014
  15. 5/5 transport-helper: fix sync issue on crashesJunio C Hamano, Apr 19, 2014
  16. Felipe ContrerasApr 20, 2014
  17. Junio C HamanoApr 20, 2014
  18. Felipe ContrerasApr 20, 2014
  19. Junio C HamanoApr 20, 2014
  20. Felipe ContrerasApr 20, 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.