|
|
|
@ -1059,11 +1059,12 @@ const struct ref *transport_get_remote_refs(struct transport *transport)
@@ -1059,11 +1059,12 @@ const struct ref *transport_get_remote_refs(struct transport *transport)
|
|
|
|
|
int transport_fetch_refs(struct transport *transport, const struct ref *refs) |
|
|
|
|
{ |
|
|
|
|
int rc; |
|
|
|
|
int nr_heads = 0, nr_alloc = 0; |
|
|
|
|
int nr_heads = 0, nr_alloc = 0, nr_refs = 0; |
|
|
|
|
const struct ref **heads = NULL; |
|
|
|
|
const struct ref *rm; |
|
|
|
|
|
|
|
|
|
for (rm = refs; rm; rm = rm->next) { |
|
|
|
|
nr_refs++; |
|
|
|
|
if (rm->peer_ref && |
|
|
|
|
!hashcmp(rm->peer_ref->old_sha1, rm->old_sha1)) |
|
|
|
|
continue; |
|
|
|
@ -1071,6 +1072,19 @@ int transport_fetch_refs(struct transport *transport, const struct ref *refs)
@@ -1071,6 +1072,19 @@ int transport_fetch_refs(struct transport *transport, const struct ref *refs)
|
|
|
|
|
heads[nr_heads++] = rm; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (!nr_heads) { |
|
|
|
|
/* |
|
|
|
|
* When deepening of a shallow repository is requested, |
|
|
|
|
* then local and remote refs are likely to still be equal. |
|
|
|
|
* Just feed them all to the fetch method in that case. |
|
|
|
|
* This condition shouldn't be met in a non-deepening fetch |
|
|
|
|
* (see builtin-fetch.c:quickfetch()). |
|
|
|
|
*/ |
|
|
|
|
heads = xmalloc(nr_refs * sizeof(*heads)); |
|
|
|
|
for (rm = refs; rm; rm = rm->next) |
|
|
|
|
heads[nr_heads++] = rm; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
rc = transport->fetch(transport, nr_heads, heads); |
|
|
|
|
free(heads); |
|
|
|
|
return rc; |
|
|
|
|