Merge branch 'np/maint-1.6.3-deepen'
* np/maint-1.6.3-deepen: fix simple deepening of a repo Conflicts: t/t5500-fetch-pack.sh
This commit is contained in:
commit
232d453766
@ -139,6 +139,36 @@ test_expect_success 'fsck in shallow repo' '
|
|||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'simple fetch in shallow repo' '
|
||||||
|
(
|
||||||
|
cd shallow &&
|
||||||
|
git fetch
|
||||||
|
)
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'no changes expected' '
|
||||||
|
(
|
||||||
|
cd shallow &&
|
||||||
|
git count-objects -v
|
||||||
|
) > count.shallow.2 &&
|
||||||
|
cmp count.shallow count.shallow.2
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'fetch same depth in shallow repo' '
|
||||||
|
(
|
||||||
|
cd shallow &&
|
||||||
|
git fetch --depth=2
|
||||||
|
)
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'no changes expected' '
|
||||||
|
(
|
||||||
|
cd shallow &&
|
||||||
|
git count-objects -v
|
||||||
|
) > count.shallow.3 &&
|
||||||
|
cmp count.shallow count.shallow.3
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'add two more' '
|
test_expect_success 'add two more' '
|
||||||
add B66 $B65 &&
|
add B66 $B65 &&
|
||||||
add B67 $B66
|
add B67 $B66
|
||||||
@ -201,4 +231,21 @@ test_expect_success 'pull in shallow repo with missing merge base' '
|
|||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'additional simple shallow deepenings' '
|
||||||
|
(
|
||||||
|
cd shallow &&
|
||||||
|
git fetch --depth=8 &&
|
||||||
|
git fetch --depth=10 &&
|
||||||
|
git fetch --depth=11
|
||||||
|
)
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'clone shallow object count' '
|
||||||
|
(
|
||||||
|
cd shallow &&
|
||||||
|
git count-objects -v
|
||||||
|
) > count.shallow &&
|
||||||
|
grep "^count: 52" count.shallow
|
||||||
|
'
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
16
transport.c
16
transport.c
@ -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 transport_fetch_refs(struct transport *transport, const struct ref *refs)
|
||||||
{
|
{
|
||||||
int rc;
|
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 **heads = NULL;
|
||||||
const struct ref *rm;
|
const struct ref *rm;
|
||||||
|
|
||||||
for (rm = refs; rm; rm = rm->next) {
|
for (rm = refs; rm; rm = rm->next) {
|
||||||
|
nr_refs++;
|
||||||
if (rm->peer_ref &&
|
if (rm->peer_ref &&
|
||||||
!hashcmp(rm->peer_ref->old_sha1, rm->old_sha1))
|
!hashcmp(rm->peer_ref->old_sha1, rm->old_sha1))
|
||||||
continue;
|
continue;
|
||||||
@ -1071,6 +1072,19 @@ int transport_fetch_refs(struct transport *transport, const struct ref *refs)
|
|||||||
heads[nr_heads++] = rm;
|
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);
|
rc = transport->fetch(transport, nr_heads, heads);
|
||||||
free(heads);
|
free(heads);
|
||||||
return rc;
|
return rc;
|
||||||
|
Loading…
Reference in New Issue
Block a user