packfile: allow install_packed_git to handle arbitrary repositories
This conversion was done without the #define trick used in the earlier series refactoring to have better repository access, because this function is easy to review, as it only has one caller and all lines but the first two are converted. We must not convert 'pack_open_fds' to be a repository specific variable, as it is used to monitor resource usage of the machine that Git executes on. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Stefan Beller committed
Mar 23, 2018 at 18:45 UTC
5babff16d9efdef8c3224d386db0b8ab2a0930d5
4 files changed
+7
-7
fast-import.c
+1
-1
@@ -1038,7 +1038,7 @@ static void end_packfile(void)
1038
if (!new_p)
1039
die("core git rejected index %s", idx_name);
1040
all_packs[pack_id] = new_p;
1041
- install_packed_git(new_p);
1041
+ install_packed_git(the_repository, new_p);
1042
free(idx_name);
1043
1044
/* Print the boundary */
http.c
+1
-1
@@ -2134,7 +2134,7 @@ int finish_http_pack_request(struct http_pack_request *preq)
2134
return -1;
2135
}
2136
2137
- install_packed_git(p);
2137
+ install_packed_git(the_repository, p);
2138
free(tmp_idx);
2139
return 0;
2140
}
packfile.c
+4
-4
@@ -680,13 +680,13 @@ struct packed_git *add_packed_git(const char *path, size_t path_len, int local)
680
return p;
681
}
682
683
-void install_packed_git(struct packed_git *pack)
683
+void install_packed_git(struct repository *r, struct packed_git *pack)
684
{
685
if (pack->pack_fd != -1)
686
pack_open_fds++;
687
688
- pack->next = the_repository->objects->packed_git;
689
- the_repository->objects->packed_git = pack;
688
+ pack->next = r->objects->packed_git;
689
+ r->objects->packed_git = pack;
690
}
691
692
void (*report_garbage)(unsigned seen_bits, const char *path);
@@ -782,7 +782,7 @@ static void prepare_packed_git_one(char *objdir, int local)
782
* corresponding .pack file that we can map.
783
*/
784
(p = add_packed_git(path.buf, path.len, local)) != NULL)
785
- install_packed_git(p);
785
+ install_packed_git(the_repository, p);
786
}
787
788
if (!report_garbage)
packfile.h
+1
-1
@@ -36,7 +36,7 @@ extern void (*report_garbage)(unsigned seen_bits, const char *path);
36
37
extern void prepare_packed_git(void);
38
extern void reprepare_packed_git(void);
39
-extern void install_packed_git(struct packed_git *pack);
39
+extern void install_packed_git(struct repository *r, struct packed_git *pack);
40
41
struct packed_git *get_packed_git(struct repository *r);
42
struct list_head *get_packed_git_mru(struct repository *r);