packfile: add repository to struct packed_git
The struct `packed_git` holds information regarding a packed object file. Let's add the repository variable to this object, to represent the repository that this packfile belongs to. This helps remove dependency on the global `the_repository` object in `packfile.c` by simply using repository information now readily available in the struct. We do need to consider that a packfile could be part of the alternates of a repository, but considering that we only have one repository struct and also that we currently anyways use 'the_repository', we should be OK with this change. We also modify `alloc_packed_git` to ensure that the repository is added to newly created `packed_git` structs. This requires modifying the function and all its callee to pass the repository object down the levels. Helped-by: Taylor Blau <me@ttaylorr.com> Signed-off-by: Karthik Nayak <karthik.188@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
8f8d6eee53
commit
2cf3fe63f6
@ -1552,7 +1552,8 @@ static void final(const char *final_pack_name, const char *curr_pack_name,
|
||||
|
||||
if (do_fsck_object) {
|
||||
struct packed_git *p;
|
||||
p = add_packed_git(final_index_name, strlen(final_index_name), 0);
|
||||
p = add_packed_git(the_repository, final_index_name,
|
||||
strlen(final_index_name), 0);
|
||||
if (p)
|
||||
install_packed_git(the_repository, p);
|
||||
}
|
||||
@ -1650,7 +1651,8 @@ static void read_v2_anomalous_offsets(struct packed_git *p,
|
||||
|
||||
static void read_idx_option(struct pack_idx_option *opts, const char *pack_name)
|
||||
{
|
||||
struct packed_git *p = add_packed_git(pack_name, strlen(pack_name), 1);
|
||||
struct packed_git *p = add_packed_git(the_repository, pack_name,
|
||||
strlen(pack_name), 1);
|
||||
|
||||
if (!p)
|
||||
die(_("Cannot open existing pack file '%s'"), pack_name);
|
||||
|
Reference in New Issue
Block a user