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

[RFC/PATCH 4/5] fetch: make the code more understandable

From
Felipe Contreras <felipe.contreras@gmail.com>
Date
Jun 4, 2019, 02:13 UTC
Message-ID
<20190604021330.16130-5-felipe.contreras@gmail.com>
In-Reply-To
<20190604021330.16130-1-felipe.contreras@gmail.com>

The comment makes it seem as if the condition is the other way around. The exception is when the oid is null, so check for that.

Signed-off-by: Felipe Contreras <felipe.contreras@gmail.com>
---
 builtin/fetch.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 8af5e319f1..9dc551551e 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -367,19 +367,21 @@ static void find_non_local_tags(const struct ref *refs,
 	 */
 	for_each_string_list_item(remote_ref_item, &remote_refs_list) {
 		const char *refname = remote_ref_item->string;
+		struct ref *rm;
 
 		item = hashmap_get_from_hash(&remote_refs, strhash(refname), refname);
 		if (!item)
 			BUG("unseen remote ref?");
 
 		/* Unless we have already decided to ignore this item... */
-		if (!is_null_oid(&item->oid)) {
-			struct ref *rm = alloc_ref(item->refname);
-			rm->peer_ref = alloc_ref(item->refname);
-			oidcpy(&rm->old_oid, &item->oid);
-			**tail = rm;
-			*tail = &rm->next;
-		}
+		if (is_null_oid(&item->oid))
+			continue;
+
+		rm = alloc_ref(item->refname);
+		rm->peer_ref = alloc_ref(item->refname);
+		oidcpy(&rm->old_oid, &item->oid);
+		**tail = rm;
+		*tail = &rm->next;
 	}
 	hashmap_free(&remote_refs, 1);
 	string_list_clear(&remote_refs_list, 0);
-- 
2.21.0
Previous: Junio C HamanoNext: Jeff King
Message 10 of 18 in “Fix fetch regression with transport helpers”
  1. 0/5 Fix fetch regression with transport helpersFelipe Contreras, Jun 4, 2019
  2. 1/5 t5801 (remote-helpers): cleanup refspec stuffFelipe Contreras, Jun 4, 2019
  3. Jeff KingJun 4, 2019
  4. 2/5 t5801 (remote-helpers): add test to fetch tagsFelipe Contreras, Jun 4, 2019
  5. Jeff KingJun 4, 2019
  6. 3/5 fetch: trivial cleanupFelipe Contreras, Jun 4, 2019
  7. 5/5 fetch: fix regression with transport helpersFelipe Contreras, Jun 4, 2019
  8. Jeff KingJun 4, 2019
  9. Junio C HamanoJun 4, 2019
  10. 4/5 fetch: make the code more understandableFelipe Contreras, Jun 4, 2019
  11. Jeff KingJun 4, 2019
  12. Felipe ContrerasJun 4, 2019
  13. Johannes SchindelinJun 5, 2019
  14. Jeff KingJun 5, 2019
  15. Duy NguyenJun 5, 2019
  16. Johannes SchindelinJun 6, 2019
  17. Junio C HamanoJun 6, 2019
  18. CI builds on GitGitGadget, was Re: [RFC/PATCH 0/5] Fix fetch regression with transport helpersJohannes Schindelin, Jun 7, 2019

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.