packfile: allow install_packed_git to handle arbitrary repositories
authorStefan Beller <sbeller@google.com>
Fri, 23 Mar 2018 17:45:18 +0000 (18:45 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 26 Mar 2018 17:07:43 +0000 (10:07 -0700)
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>
fast-import.c
http.c
packfile.c
packfile.h
index b3492fce5c440763d14d64c63537c18ca0186b82..ae4ced3ae186a7c6d323e580fe5fa1873fb67b3b 100644 (file)
@@ -1038,7 +1038,7 @@ static void end_packfile(void)
                if (!new_p)
                        die("core git rejected index %s", idx_name);
                all_packs[pack_id] = new_p;
-               install_packed_git(new_p);
+               install_packed_git(the_repository, new_p);
                free(idx_name);
 
                /* Print the boundary */
diff --git a/http.c b/http.c
index 4d613d5f6bc3fbcda9db68f678f34238735c973b..111e3c12c8e5edecf09289b6dc79fda232b55938 100644 (file)
--- a/http.c
+++ b/http.c
@@ -2134,7 +2134,7 @@ int finish_http_pack_request(struct http_pack_request *preq)
                return -1;
        }
 
-       install_packed_git(p);
+       install_packed_git(the_repository, p);
        free(tmp_idx);
        return 0;
 }
index 326c171e9804f74d2478f70d4b7e991ffce44b3b..94987634e517e83a8350d9a0870fc1da5634cc2c 100644 (file)
@@ -680,13 +680,13 @@ struct packed_git *add_packed_git(const char *path, size_t path_len, int local)
        return p;
 }
 
-void install_packed_git(struct packed_git *pack)
+void install_packed_git(struct repository *r, struct packed_git *pack)
 {
        if (pack->pack_fd != -1)
                pack_open_fds++;
 
-       pack->next = the_repository->objects->packed_git;
-       the_repository->objects->packed_git = pack;
+       pack->next = r->objects->packed_git;
+       r->objects->packed_git = pack;
 }
 
 void (*report_garbage)(unsigned seen_bits, const char *path);
@@ -782,7 +782,7 @@ static void prepare_packed_git_one(char *objdir, int local)
                             * corresponding .pack file that we can map.
                             */
                            (p = add_packed_git(path.buf, path.len, local)) != NULL)
-                               install_packed_git(p);
+                               install_packed_git(the_repository, p);
                }
 
                if (!report_garbage)
index 5b1ce00f848dad149f638b66eb2d1341205045e1..77442172f03fc4911bd570a2537d1141bee8eb2b 100644 (file)
@@ -36,7 +36,7 @@ extern void (*report_garbage)(unsigned seen_bits, const char *path);
 
 extern void prepare_packed_git(void);
 extern void reprepare_packed_git(void);
-extern void install_packed_git(struct packed_git *pack);
+extern void install_packed_git(struct repository *r, struct packed_git *pack);
 
 struct packed_git *get_packed_git(struct repository *r);
 struct list_head *get_packed_git_mru(struct repository *r);