object-store: close all packs upon clearing the object store
authorStefan Beller <sbeller@google.com>
Fri, 23 Mar 2018 17:21:00 +0000 (18:21 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 26 Mar 2018 17:05:55 +0000 (10:05 -0700)
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>
builtin/am.c
builtin/clone.c
builtin/fetch.c
builtin/merge.c
builtin/receive-pack.c
object.c
packfile.c
packfile.h
index 5bdd2d75781076636f93800520e9ed161295724f..47beddbe24040d81dea28a61d9e7f7bd0e791653 100644 (file)
@@ -1859,7 +1859,7 @@ static void am_run(struct am_state *state, int resume)
         */
        if (!state->rebasing) {
                am_destroy(state);
-               close_all_packs();
+               close_all_packs(the_repository->objects);
                run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
        }
 }
index 855947f1aba9bd052d5e3edb42f4174ae45a0579..7df5932b855e874d45b970f6150d65ed25b06f5f 100644 (file)
@@ -1218,7 +1218,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
        transport_disconnect(transport);
 
        if (option_dissociate) {
-               close_all_packs();
+               close_all_packs(the_repository->objects);
                dissociate_from_references();
        }
 
index 8ee998ea2ee8f736a49afe285d31b0be478cf15b..a39e9d7b1579fd6adb8d421ac8984bc0592b5eda 100644 (file)
@@ -1478,7 +1478,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
 
        string_list_clear(&list, 0);
 
-       close_all_packs();
+       close_all_packs(the_repository->objects);
 
        argv_array_pushl(&argv_gc_auto, "gc", "--auto", NULL);
        if (verbosity < 0)
index 30264cfd7c1720aee814699eb3ca057e292b082d..96d56cbdd2f2bbb9a76d2027037b54f32c892c23 100644 (file)
@@ -411,7 +411,7 @@ static void finish(struct commit *head_commit,
                         * We ignore errors in 'gc --auto', since the
                         * user should see them.
                         */
-                       close_all_packs();
+                       close_all_packs(the_repository->objects);
                        run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
                }
        }
index b7ce7c7f5275febbf6db6b71e3b610b09a4fe191..1a298a6711687ccdbd65f088a2bcbc557bef9f10 100644 (file)
@@ -2026,7 +2026,7 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
                        proc.git_cmd = 1;
                        proc.argv = argv_gc_auto;
 
-                       close_all_packs();
+                       close_all_packs(the_repository->objects);
                        if (!start_command(&proc)) {
                                if (use_sideband)
                                        copy_to_sideband(proc.err, -1, NULL);
index 04631ee841bc857eb09cde5cdb6e15dd8af555e6..4c2cf7ff5d525b8559fc9099b1b957b0e61f3f97 100644 (file)
--- a/object.c
+++ b/object.c
@@ -5,6 +5,7 @@
 #include "commit.h"
 #include "tag.h"
 #include "object-store.h"
+#include "packfile.h"
 
 static struct object **obj_hash;
 static int nr_objs, obj_hash_size;
@@ -483,8 +484,6 @@ void raw_object_store_clear(struct raw_object_store *o)
        o->alt_odb_tail = NULL;
 
        INIT_LIST_HEAD(&o->packed_git_mru);
-       /*
-        * TODO: call close_all_packs once migrated to
-        * take an object store argument
-        */
+       close_all_packs(o);
+       o->packed_git = NULL;
 }
index b56ed10b68ac54eda414b673b65a1a3df04ae9e9..8b27b69bff26cab34bf67ad3e7f8a2b7c5f0a4b4 100644 (file)
@@ -311,11 +311,11 @@ static void close_pack(struct packed_git *p)
        close_pack_index(p);
 }
 
-void close_all_packs(void)
+void close_all_packs(struct raw_object_store *o)
 {
        struct packed_git *p;
 
-       for (p = the_repository->objects->packed_git; p; p = p->next)
+       for (p = o->packed_git; p; p = p->next)
                if (p->do_not_close)
                        die("BUG: want to close pack marked 'do-not-close'");
                else
index 76496226bb07eecd759d8eafa0536c3bb98e9e2c..5b1ce00f848dad149f638b66eb2d1341205045e1 100644 (file)
@@ -66,7 +66,7 @@ extern void close_pack_index(struct packed_git *);
 
 extern unsigned char *use_pack(struct packed_git *, struct pack_window **, off_t, unsigned long *);
 extern void close_pack_windows(struct packed_git *);
-extern void close_all_packs(void);
+extern void close_all_packs(struct raw_object_store *o);
 extern void unuse_pack(struct pack_window **);
 extern void clear_delta_base_cache(void);
 extern struct packed_git *add_packed_git(const char *path, size_t path_len, int local);