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

[PATCH] transport-helper: die on errors reading refs.

From
Stefan Beller <sbeller@google.com>
Date
Jul 31, 2015, 23:57 UTC
Message-ID
<1438387077-10181-1-git-send-email-sbeller@google.com>

We check the return value of read_ref in 19 out of 21 cases. This adds checks to the missing cases.

Signed-off-by: Stefan Beller <sbeller@google.com>
---
 transport-helper.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/transport-helper.c b/transport-helper.c
index 5d99a6b..68e498e 100644
--- a/transport-helper.c
+++ b/transport-helper.c
@@ -490,7 +490,8 @@ static int fetch_with_import(struct transport *transport,
 		else
 			private = xstrdup(name);
 		if (private) {
-			read_ref(private, posn->old_sha1);
+			if (read_ref(private, posn->old_sha1) < 0)
+				die("Could not read ref %s", private);
 			free(private);
 		}
 	}
@@ -1019,7 +1020,10 @@ static struct ref *get_refs_list(struct transport *transport, int for_push)
 		if (eon) {
 			if (has_attribute(eon + 1, "unchanged")) {
 				(*tail)->status |= REF_STATUS_UPTODATE;
-				read_ref((*tail)->name, (*tail)->old_sha1);
+				if (read_ref((*tail)->name,
+					     (*tail)->old_sha1) < 0)
+					die(N_("Could not read ref %s"),
+					    (*tail)->name);
 			}
 		}
 		tail = &((*tail)->next);
-- 
2.5.0.5.gf4cd9ae.dirty
Message 1 of 1 in “transport-helper: die on errors reading refs.”
  1. transport-helper: die on errors reading refs.Stefan Beller, Jul 31, 2015

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.