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

[PATCH] http-push: don't check return value of lookup_unknown_object()

From
René Scharfe <l.s.r@web.de>
Date
Mar 17, 2017, 22:12 UTC
Message-ID
<1a7123f5-9017-7602-03f4-5123cdebe541@web.de>

This function always returns a reference to an object, creating one if needed, so remove the unnecessary NULL check.

Signed-off-by: Rene Scharfe <l.s.r@web.de>
---
 http-push.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/http-push.c b/http-push.c
index 704b1c837c..f0e3108f71 100644
--- a/http-push.c
+++ b/http-push.c
@@ -1431,11 +1431,9 @@ static void one_remote_ref(const char *refname)
 	 */
 	if (repo->can_update_info_refs && !has_object_file(&ref->old_oid)) {
 		obj = lookup_unknown_object(ref->old_oid.hash);
-		if (obj) {
-			fprintf(stderr,	"  fetch %s for %s\n",
-				oid_to_hex(&ref->old_oid), refname);
-			add_fetch_request(obj);
-		}
+		fprintf(stderr,	"  fetch %s for %s\n",
+			oid_to_hex(&ref->old_oid), refname);
+		add_fetch_request(obj);
 	}
 
 	ref->next = remote_refs;
-- 
2.12.0
Message 1 of 1 in “http-push: don't check return value of lookup_unknown_object()”
  1. http-push: don't check return value of lookup_unknown_object()René Scharfe, Mar 17, 2017

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.