object-store: close all packs upon clearing the object store
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:21 UTC
d0b59866223f7ef0dcd07bff857f651cd921bc02
8 files changed
+11
-12
builtin/am.c
+1
-1
@@ -1859,7 +1859,7 @@ next:
1859
*/
1860
if (!state->rebasing) {
1861
am_destroy(state);
1862
- close_all_packs();
1862
+ close_all_packs(the_repository->objects);
1863
run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
1864
}
1865
}
builtin/clone.c
+1
-1
@@ -1218,7 +1218,7 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
1218
transport_disconnect(transport);
1219
1220
if (option_dissociate) {
1221
- close_all_packs();
1221
+ close_all_packs(the_repository->objects);
1222
dissociate_from_references();
1223
}
1224
builtin/fetch.c
+1
-1
@@ -1478,7 +1478,7 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
1478
1479
string_list_clear(&list, 0);
1480
1481
- close_all_packs();
1481
+ close_all_packs(the_repository->objects);
1482
1483
argv_array_pushl(&argv_gc_auto, "gc", "--auto", NULL);
1484
if (verbosity < 0)
builtin/merge.c
+1
-1
@@ -411,7 +411,7 @@ static void finish(struct commit *head_commit,
411
* We ignore errors in 'gc --auto', since the
412
* user should see them.
413
*/
414
- close_all_packs();
414
+ close_all_packs(the_repository->objects);
415
run_command_v_opt(argv_gc_auto, RUN_GIT_CMD);
416
}
417
}
builtin/receive-pack.c
+1
-1
@@ -2026,7 +2026,7 @@ int cmd_receive_pack(int argc, const char **argv, const char *prefix)
2026
proc.git_cmd = 1;
2027
proc.argv = argv_gc_auto;
2028
2029
- close_all_packs();
2029
+ close_all_packs(the_repository->objects);
2030
if (!start_command(&proc)) {
2031
if (use_sideband)
2032
copy_to_sideband(proc.err, -1, NULL);
object.c
+3
-4
@@ -5,6 +5,7 @@
5
#include "commit.h"
6
#include "tag.h"
7
#include "object-store.h"
8
+#include "packfile.h"
9
10
static struct object **obj_hash;
11
static int nr_objs, obj_hash_size;
@@ -483,8 +484,6 @@ void raw_object_store_clear(struct raw_object_store *o)
484
o->alt_odb_tail = NULL;
485
486
INIT_LIST_HEAD(&o->packed_git_mru);
486
- /*
487
- * TODO: call close_all_packs once migrated to
488
- * take an object store argument
489
- */
487
+ close_all_packs(o);
488
+ o->packed_git = NULL;
489
}
packfile.c
+2
-2
@@ -311,11 +311,11 @@ static void close_pack(struct packed_git *p)
311
close_pack_index(p);
312
}
313
314
-void close_all_packs(void)
314
+void close_all_packs(struct raw_object_store *o)
315
{
316
struct packed_git *p;
317
318
- for (p = the_repository->objects->packed_git; p; p = p->next)
318
+ for (p = o->packed_git; p; p = p->next)
319
if (p->do_not_close)
320
die("BUG: want to close pack marked 'do-not-close'");
321
else
packfile.h
+1
-1
@@ -66,7 +66,7 @@ extern void close_pack_index(struct packed_git *);
66
67
extern unsigned char *use_pack(struct packed_git *, struct pack_window **, off_t, unsigned long *);
68
extern void close_pack_windows(struct packed_git *);
69
-extern void close_all_packs(void);
69
+extern void close_all_packs(struct raw_object_store *o);
70
extern void unuse_pack(struct pack_window **);
71
extern void clear_delta_base_cache(void);
72
extern struct packed_git *add_packed_git(const char *path, size_t path_len, int local);