Skip to content

Commit f6f236d

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 78237ea commit f6f236d

File tree

7 files changed

+18
-12
lines changed

7 files changed

+18
-12
lines changed

builtin/fast-import.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,7 @@ static void end_packfile(void)
901901
if (!new_p)
902902
die("core git rejected index %s", idx_name);
903903
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);
905905
free(idx_name);
906906

907907
/* Print the boundary */

builtin/index-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1645,7 +1645,7 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
16451645
p = add_packed_git(the_repository, final_index_name,
16461646
strlen(final_index_name), 0);
16471647
if (p)
1648-
install_packed_git(the_repository, p);
1648+
packfile_store_add_pack(the_repository->objects->packfiles, p);
16491649
}
16501650

16511651
if (!from_stdin) {

http.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2541,7 +2541,7 @@ void http_install_packfile(struct packed_git *p,
25412541
lst = &((*lst)->next);
25422542
*lst = (*lst)->next;
25432543

2544-
install_packed_git(the_repository, p);
2544+
packfile_store_add_pack(the_repository->objects->packfiles, p);
25452545
}
25462546

25472547
struct http_pack_request *new_http_pack_request(

http.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ int finish_http_pack_request(struct http_pack_request *preq);
210210
void release_http_pack_request(struct http_pack_request *preq);
211211

212212
/*
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.
214214
*
215215
* This is a convenience function for users that have obtained a list of packs
216216
* from http_get_info_packs() and have chosen a specific pack to fetch.

midx.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ int prepare_midx_pack(struct multi_pack_index *m,
467467
p = add_packed_git(r, pack_name.buf, pack_name.len,
468468
m->source->local);
469469
if (p) {
470-
install_packed_git(r, p);
470+
packfile_store_add_pack(r->objects->packfiles, p);
471471
list_add_tail(&p->mru, &r->objects->packfiles->mru);
472472
}
473473
}

packfile.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -779,16 +779,17 @@ struct packed_git *add_packed_git(struct repository *r, const char *path,
779779
return p;
780780
}
781781

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)
783784
{
784785
if (pack->pack_fd != -1)
785786
pack_open_fds++;
786787

787-
pack->next = r->objects->packfiles->packs;
788-
r->objects->packfiles->packs = pack;
788+
pack->next = store->packs;
789+
store->packs = pack;
789790

790791
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);
792793
}
793794

794795
void (*report_garbage)(unsigned seen_bits, const char *path);
@@ -904,7 +905,7 @@ static void prepare_pack(const char *full_name, size_t full_name_len,
904905
if (!hashmap_get(&data->r->objects->packfiles->map, &hent, pack_name)) {
905906
p = add_packed_git(data->r, full_name, full_name_len, data->local);
906907
if (p)
907-
install_packed_git(data->r, p);
908+
packfile_store_add_pack(data->r->objects->packfiles, p);
908909
}
909910
free(pack_name);
910911
}

packfile.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,13 @@ void packfile_store_close(struct packfile_store *store);
120120
*/
121121
void packfile_store_reprepare(struct packfile_store *store);
122122

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+
123130
struct pack_window {
124131
struct pack_window *next;
125132
unsigned char *base;
@@ -196,8 +203,6 @@ int for_each_packed_object(struct repository *repo, each_packed_object_fn cb,
196203
#define PACKDIR_FILE_GARBAGE 4
197204
extern void (*report_garbage)(unsigned seen_bits, const char *path);
198205

199-
void install_packed_git(struct repository *r, struct packed_git *pack);
200-
201206
struct packed_git *get_packed_git(struct repository *r);
202207
struct list_head *get_packed_git_mru(struct repository *r);
203208
struct multi_pack_index *get_multi_pack_index(struct odb_source *source);

0 commit comments

Comments
 (0)