Git fork

packfile: refactor `install_packed_git()` to work on packfile store

The `install_packed_git()` functions adds a packfile to a specific
object store. Refactor it to accept a packfile store instead of a
repository to clarify its scope.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Patrick Steinhardt and committed by
Junio C Hamano
f6f236d9 78237ea5

+18 -12
+1 -1
builtin/fast-import.c
··· 901 901 if (!new_p) 902 902 die("core git rejected index %s", idx_name); 903 903 all_packs[pack_id] = new_p; 904 - install_packed_git(the_repository, new_p); 904 + packfile_store_add_pack(the_repository->objects->packfiles, new_p); 905 905 free(idx_name); 906 906 907 907 /* Print the boundary */
+1 -1
builtin/index-pack.c
··· 1645 1645 p = add_packed_git(the_repository, final_index_name, 1646 1646 strlen(final_index_name), 0); 1647 1647 if (p) 1648 - install_packed_git(the_repository, p); 1648 + packfile_store_add_pack(the_repository->objects->packfiles, p); 1649 1649 } 1650 1650 1651 1651 if (!from_stdin) {
+1 -1
http.c
··· 2541 2541 lst = &((*lst)->next); 2542 2542 *lst = (*lst)->next; 2543 2543 2544 - install_packed_git(the_repository, p); 2544 + packfile_store_add_pack(the_repository->objects->packfiles, p); 2545 2545 } 2546 2546 2547 2547 struct http_pack_request *new_http_pack_request(
+1 -1
http.h
··· 210 210 void release_http_pack_request(struct http_pack_request *preq); 211 211 212 212 /* 213 - * Remove p from the given list, and invoke install_packed_git() on it. 213 + * Remove p from the given list, and invoke packfile_store_add_pack() on it. 214 214 * 215 215 * This is a convenience function for users that have obtained a list of packs 216 216 * from http_get_info_packs() and have chosen a specific pack to fetch.
+1 -1
midx.c
··· 467 467 p = add_packed_git(r, pack_name.buf, pack_name.len, 468 468 m->source->local); 469 469 if (p) { 470 - install_packed_git(r, p); 470 + packfile_store_add_pack(r->objects->packfiles, p); 471 471 list_add_tail(&p->mru, &r->objects->packfiles->mru); 472 472 } 473 473 }
+6 -5
packfile.c
··· 779 779 return p; 780 780 } 781 781 782 - void install_packed_git(struct repository *r, struct packed_git *pack) 782 + void packfile_store_add_pack(struct packfile_store *store, 783 + struct packed_git *pack) 783 784 { 784 785 if (pack->pack_fd != -1) 785 786 pack_open_fds++; 786 787 787 - pack->next = r->objects->packfiles->packs; 788 - r->objects->packfiles->packs = pack; 788 + pack->next = store->packs; 789 + store->packs = pack; 789 790 790 791 hashmap_entry_init(&pack->packmap_ent, strhash(pack->pack_name)); 791 - hashmap_add(&r->objects->packfiles->map, &pack->packmap_ent); 792 + hashmap_add(&store->map, &pack->packmap_ent); 792 793 } 793 794 794 795 void (*report_garbage)(unsigned seen_bits, const char *path); ··· 904 905 if (!hashmap_get(&data->r->objects->packfiles->map, &hent, pack_name)) { 905 906 p = add_packed_git(data->r, full_name, full_name_len, data->local); 906 907 if (p) 907 - install_packed_git(data->r, p); 908 + packfile_store_add_pack(data->r->objects->packfiles, p); 908 909 } 909 910 free(pack_name); 910 911 }
+7 -2
packfile.h
··· 120 120 */ 121 121 void packfile_store_reprepare(struct packfile_store *store); 122 122 123 + /* 124 + * Add the pack to the store so that contained objects become accessible via 125 + * the store. This moves ownership into the store. 126 + */ 127 + void packfile_store_add_pack(struct packfile_store *store, 128 + struct packed_git *pack); 129 + 123 130 struct pack_window { 124 131 struct pack_window *next; 125 132 unsigned char *base; ··· 195 202 #define PACKDIR_FILE_IDX 2 196 203 #define PACKDIR_FILE_GARBAGE 4 197 204 extern void (*report_garbage)(unsigned seen_bits, const char *path); 198 - 199 - void install_packed_git(struct repository *r, struct packed_git *pack); 200 205 201 206 struct packed_git *get_packed_git(struct repository *r); 202 207 struct list_head *get_packed_git_mru(struct repository *r);