fetch: refactor fetch_refs into two functions
Refactor the fetch_refs function into a function that does the fetching of refs and another function that stores them. This is in preparation for allowing additional processing of the fetched refs before updating the local ref store. Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
14b8ced376
commit
05c4422676
@ -968,9 +968,21 @@ static int fetch_refs(struct transport *transport, struct ref *ref_map)
|
|||||||
if (ret)
|
if (ret)
|
||||||
ret = transport_fetch_refs(transport, ref_map);
|
ret = transport_fetch_refs(transport, ref_map);
|
||||||
if (!ret)
|
if (!ret)
|
||||||
ret |= store_updated_refs(transport->url,
|
/*
|
||||||
transport->remote->name,
|
* Keep the new pack's ".keep" file around to allow the caller
|
||||||
ref_map);
|
* time to update refs to reference the new objects.
|
||||||
|
*/
|
||||||
|
return 0;
|
||||||
|
transport_unlock_pack(transport);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Update local refs based on the ref values fetched from a remote */
|
||||||
|
static int consume_refs(struct transport *transport, struct ref *ref_map)
|
||||||
|
{
|
||||||
|
int ret = store_updated_refs(transport->url,
|
||||||
|
transport->remote->name,
|
||||||
|
ref_map);
|
||||||
transport_unlock_pack(transport);
|
transport_unlock_pack(transport);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -1116,7 +1128,8 @@ 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_FOLLOWTAGS, NULL);
|
||||||
transport_set_option(transport, TRANS_OPT_DEPTH, "0");
|
transport_set_option(transport, TRANS_OPT_DEPTH, "0");
|
||||||
transport_set_option(transport, TRANS_OPT_DEEPEN_RELATIVE, NULL);
|
transport_set_option(transport, TRANS_OPT_DEEPEN_RELATIVE, NULL);
|
||||||
fetch_refs(transport, ref_map);
|
if (!fetch_refs(transport, ref_map))
|
||||||
|
consume_refs(transport, ref_map);
|
||||||
|
|
||||||
if (gsecondary) {
|
if (gsecondary) {
|
||||||
transport_disconnect(gsecondary);
|
transport_disconnect(gsecondary);
|
||||||
@ -1165,7 +1178,7 @@ static int do_fetch(struct transport *transport,
|
|||||||
transport->url);
|
transport->url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fetch_refs(transport, ref_map)) {
|
if (fetch_refs(transport, ref_map) || consume_refs(transport, ref_map)) {
|
||||||
free_refs(ref_map);
|
free_refs(ref_map);
|
||||||
retcode = 1;
|
retcode = 1;
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
Loading…
Reference in New Issue
Block a user