fetch: refactor code that fetches leftover tags

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>

Junio C Hamano committed Aug 7, 2013 at 15:14 UTC 069d50320257b76504921a7bc77696a6d858bfec
1 file changed +9 -5
builtin/fetch.c
+9 -5
@@ -745,6 +745,13 @@ struct transport *prepare_transport(struct remote *remote)
745 return transport;
746 }
747
748 +static void backfill_tags(struct transport *transport, struct ref *ref_map)
749 +{
750 + transport_set_option(transport, TRANS_OPT_FOLLOWTAGS, NULL);
751 + transport_set_option(transport, TRANS_OPT_DEPTH, "0");
752 + fetch_refs(transport, ref_map);
753 +}
754 +
755 static int do_fetch(struct transport *transport,
756 struct refspec *refs, int ref_count)
757 {
@@ -828,11 +835,8 @@ static int do_fetch(struct transport *transport,
835 struct ref **tail = &ref_map;
836 ref_map = NULL;
837 find_non_local_tags(transport, &ref_map, &tail);
831 - if (ref_map) {
832 - transport_set_option(transport, TRANS_OPT_FOLLOWTAGS, NULL);
833 - transport_set_option(transport, TRANS_OPT_DEPTH, "0");
834 - fetch_refs(transport, ref_map);
835 - }
838 + if (ref_map)
839 + backfill_tags(transport, ref_map);
840 free_refs(ref_map);
841 }
842