mirror of
https://github.com/git/git.git
synced 2024-11-15 15:03:47 +01:00
Merge branch 'ds/partial-clone-fixes'
Fix for a bug revealed by a recent change to make the protocol v2 the default. * ds/partial-clone-fixes: partial-clone: avoid fetching when looking for objects partial-clone: demonstrate bugs in partial fetch
This commit is contained in:
commit
444cff61b4
@ -335,6 +335,7 @@ static void find_non_local_tags(const struct ref *refs,
|
||||
struct string_list_item *remote_ref_item;
|
||||
const struct ref *ref;
|
||||
struct refname_hash_entry *item = NULL;
|
||||
const int quick_flags = OBJECT_INFO_QUICK | OBJECT_INFO_SKIP_FETCH_OBJECT;
|
||||
|
||||
refname_hash_init(&existing_refs);
|
||||
refname_hash_init(&remote_refs);
|
||||
@ -353,10 +354,9 @@ static void find_non_local_tags(const struct ref *refs,
|
||||
*/
|
||||
if (ends_with(ref->name, "^{}")) {
|
||||
if (item &&
|
||||
!has_object_file_with_flags(&ref->old_oid,
|
||||
OBJECT_INFO_QUICK) &&
|
||||
!has_object_file_with_flags(&ref->old_oid, quick_flags) &&
|
||||
!oidset_contains(&fetch_oids, &ref->old_oid) &&
|
||||
!has_object_file_with_flags(&item->oid, OBJECT_INFO_QUICK) &&
|
||||
!has_object_file_with_flags(&item->oid, quick_flags) &&
|
||||
!oidset_contains(&fetch_oids, &item->oid))
|
||||
clear_item(item);
|
||||
item = NULL;
|
||||
@ -370,7 +370,7 @@ static void find_non_local_tags(const struct ref *refs,
|
||||
* fetch.
|
||||
*/
|
||||
if (item &&
|
||||
!has_object_file_with_flags(&item->oid, OBJECT_INFO_QUICK) &&
|
||||
!has_object_file_with_flags(&item->oid, quick_flags) &&
|
||||
!oidset_contains(&fetch_oids, &item->oid))
|
||||
clear_item(item);
|
||||
|
||||
@ -391,7 +391,7 @@ static void find_non_local_tags(const struct ref *refs,
|
||||
* checked to see if it needs fetching.
|
||||
*/
|
||||
if (item &&
|
||||
!has_object_file_with_flags(&item->oid, OBJECT_INFO_QUICK) &&
|
||||
!has_object_file_with_flags(&item->oid, quick_flags) &&
|
||||
!oidset_contains(&fetch_oids, &item->oid))
|
||||
clear_item(item);
|
||||
|
||||
|
@ -384,6 +384,37 @@ test_expect_success 'fetch lazy-fetches only to resolve deltas, protocol v2' '
|
||||
grep "want $(cat hash)" trace
|
||||
'
|
||||
|
||||
# The following two tests must be in this order, or else
|
||||
# the first will not fail. It is important that the srv.bare
|
||||
# repository did not have tags during clone, but has tags
|
||||
# in the fetch.
|
||||
|
||||
test_expect_failure 'verify fetch succeeds when asking for new tags' '
|
||||
git clone --filter=blob:none "file://$(pwd)/srv.bare" tag-test &&
|
||||
for i in I J K
|
||||
do
|
||||
test_commit -C src $i &&
|
||||
git -C src branch $i || return 1
|
||||
done &&
|
||||
git -C srv.bare fetch --tags origin +refs/heads/*:refs/heads/* &&
|
||||
git -C tag-test -c protocol.version=2 fetch --tags origin
|
||||
'
|
||||
|
||||
test_expect_success 'verify fetch downloads only one pack when updating refs' '
|
||||
git clone --filter=blob:none "file://$(pwd)/srv.bare" pack-test &&
|
||||
ls pack-test/.git/objects/pack/*pack >pack-list &&
|
||||
test_line_count = 2 pack-list &&
|
||||
for i in A B C
|
||||
do
|
||||
test_commit -C src $i &&
|
||||
git -C src branch $i || return 1
|
||||
done &&
|
||||
git -C srv.bare fetch origin +refs/heads/*:refs/heads/* &&
|
||||
git -C pack-test fetch origin &&
|
||||
ls pack-test/.git/objects/pack/*pack >pack-list &&
|
||||
test_line_count = 3 pack-list
|
||||
'
|
||||
|
||||
. "$TEST_DIRECTORY"/lib-httpd.sh
|
||||
start_httpd
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user