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

[PATCH 4/5] fetch: refactor code that fetches leftover tags

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 7, 2013, 23:30 UTC
Message-ID
<1375918242-4655-5-git-send-email-gitster@pobox.com>
In-Reply-To
<1375918242-4655-1-git-send-email-gitster@pobox.com>

Usually the upload-pack process running on the other side will give us all the reachable tags we need during the primary object transfer in do_fetch(). If that does not happen (e.g. the other side may be running a third-party implementation of upload-pack), we will run another fetch to pick up leftover tags that we know point at the commits reachable from our updated tips.

Separate out the code to run this second fetch into a helper function.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 builtin/fetch.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
diff --git a/builtin/fetch.c b/builtin/fetch.c
index 39a3fc8..0b21f07 100644
--- a/builtin/fetch.c
+++ b/builtin/fetch.c
@@ -745,6 +745,13 @@ struct transport *prepare_transport(struct remote *remote)
 	return transport;
 }
 
+static void backfill_tags(struct transport *transport, struct ref *ref_map)
+{
+	transport_set_option(transport, TRANS_OPT_FOLLOWTAGS, NULL);
+	transport_set_option(transport, TRANS_OPT_DEPTH, "0");
+	fetch_refs(transport, ref_map);
+}
+
 static int do_fetch(struct transport *transport,
 		    struct refspec *refs, int ref_count)
 {
@@ -828,11 +835,8 @@ static int do_fetch(struct transport *transport,
 		struct ref **tail = &ref_map;
 		ref_map = NULL;
 		find_non_local_tags(transport, &ref_map, &tail);
-		if (ref_map) {
-			transport_set_option(transport, TRANS_OPT_FOLLOWTAGS, NULL);
-			transport_set_option(transport, TRANS_OPT_DEPTH, "0");
-			fetch_refs(transport, ref_map);
-		}
+		if (ref_map)
+			backfill_tags(transport, ref_map);
 		free_refs(ref_map);
 	}
 
-- 
1.8.4-rc1-210-gf6d87e2
Previous: Junio C HamanoNext: Junio C Hamano
Message 5 of 6 in “work around "transport-take-over" hack”
  1. 0/5 work around "transport-take-over" hackJunio C Hamano, Aug 7, 2013
  2. 1/5 t5802: add test for connect helperJunio C Hamano, Aug 7, 2013
  3. 2/5 fetch: rename file-scope global "transport" to "gtransport"Junio C Hamano, Aug 7, 2013
  4. 3/5 fetch: refactor code that prepares a transportJunio C Hamano, Aug 7, 2013
  5. 4/5 fetch: refactor code that fetches leftover tagsJunio C Hamano, Aug 7, 2013
  6. 5/5 fetch: work around "transport-take-over" hackJunio C Hamano, Aug 7, 2013

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.