Skip to content

Commit 069d503

Browse files
committed
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 <[email protected]>
1 parent db5723c commit 069d503

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

builtin/fetch.c

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -745,6 +745,13 @@ struct transport *prepare_transport(struct remote *remote)
745745
return transport;
746746
}
747747

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+
748755
static int do_fetch(struct transport *transport,
749756
struct refspec *refs, int ref_count)
750757
{
@@ -828,11 +835,8 @@ static int do_fetch(struct transport *transport,
828835
struct ref **tail = &ref_map;
829836
ref_map = NULL;
830837
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);
836840
free_refs(ref_map);
837841
}
838842

0 commit comments

Comments
 (0)