Skip to content

Commit 72f6d6d

Browse files
authored
Fix infinite loop in packfile MRU after prefetch packs are added (#822)
This fixup updates b46ad0a (gvfs-helper: create tool to fetch objects using the GVFS Protocol, 2019-08-13) in reaction to f6f236d (packfile: refactor `install_packed_git()` to work on packfile store, 2025-09-23) which is included in Git 2.52.0. This PR is organized to fixup the commit mentioned above and to drop 4e743e6 (packfile: add install_packed_git_and_mru(), 2019-09-25) now that the packfile method is no longer used. The refactored packfile store includes an automatic inclusion of new packifles into the MRU list. This introduces a bug in microsoft/git's use of the GVFS protocol in the following scenario in 'git fetch': 1. If the prefetch downloads at least one prefetch packfile, then it is added to the MRU list twice, creating an infinite loop. 2. If the refs that are updated include commits that are not present in the packfile list, then the MRU lookup will iterate through without interruption, hitting the infinite loop. The fix is to modify this patch to no longer include a custom "add to MRU" method now that the default implementation does this for us. * [X] This change only applies to interactions with Azure DevOps and the GVFS Protocol.
2 parents df57b45 + 13b8048 commit 72f6d6d

File tree

3 files changed

+1
-16
lines changed

3 files changed

+1
-16
lines changed

gvfs-helper-client.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ static void gh_client__update_packed_git(const char *line)
216216

217217
p = add_packed_git(the_repository, path.buf, path.len, is_local);
218218
if (p)
219-
packfile_store_add_pack_also_to_mru(the_repository, p);
219+
packfile_store_add_pack(the_repository->objects->packfiles, p);
220220
strbuf_release(&path);
221221
}
222222

packfile.c

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -792,14 +792,6 @@ void packfile_store_add_pack(struct packfile_store *store,
792792
hashmap_add(&store->map, &pack->packmap_ent);
793793
}
794794

795-
void packfile_store_add_pack_also_to_mru(struct repository *r,
796-
struct packed_git *pack)
797-
{
798-
packfile_store_add_pack(r->objects->packfiles, pack);
799-
list_add(&pack->mru,
800-
packfile_store_get_packs_mru(r->objects->packfiles));
801-
}
802-
803795
struct packed_git *packfile_store_load_pack(struct packfile_store *store,
804796
const char *idx_path, int local)
805797
{

packfile.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,6 @@ void packfile_store_reprepare(struct packfile_store *store);
135135
*/
136136
void packfile_store_add_pack(struct packfile_store *store,
137137
struct packed_git *pack);
138-
/*
139-
* Add the pack to the store so that contained objects become accessible via
140-
* the store, and then mark it as most recently used. This moves ownership into
141-
* the store.
142-
*/
143-
void packfile_store_add_pack_also_to_mru(struct repository *r,
144-
struct packed_git *pack);
145138

146139
/*
147140
* Load and iterate through all packs of the given repository. This helper

0 commit comments

Comments
 (0)