From 1dcd9f2043a38f0c9684d47c71b9e383942660ac Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Fri, 12 Oct 2018 10:34:19 -0700 Subject: midx: close multi-pack-index on repack When repacking, we may remove pack-files. This invalidates the multi-pack-index (if it exists). Previously, we removed the multi-pack-index file before removing any pack-file. In some cases, the repack command may load the multi-pack-index into memory. This may lead to later in-memory references to the non-existent pack- files. Signed-off-by: Derrick Stolee Signed-off-by: Junio C Hamano --- midx.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'midx.h') diff --git a/midx.h b/midx.h index a210f1af2a..7e60907596 100644 --- a/midx.h +++ b/midx.h @@ -42,6 +42,8 @@ int midx_contains_pack(struct multi_pack_index *m, const char *idx_name); int prepare_multi_pack_index_one(struct repository *r, const char *object_dir, int local); int write_midx_file(const char *object_dir); -void clear_midx_file(const char *object_dir); +void clear_midx_file(struct repository *r); + +void close_midx(struct multi_pack_index *m); #endif -- cgit v1.2.3 From 0465a50506023df0932fe0534fe6ac6712c0d854 Mon Sep 17 00:00:00 2001 From: Derrick Stolee Date: Fri, 12 Oct 2018 10:34:20 -0700 Subject: multi-pack-index: define GIT_TEST_MULTI_PACK_INDEX The multi-pack-index feature is tested in isolation by t5319-multi-pack-index.sh, but there are many more interesting scenarios in the test suite surrounding pack-file data shapes and interactions. Since the multi-pack-index is an optional data structure, it does not make sense to include it by default in those tests. Instead, add a new GIT_TEST_MULTI_PACK_INDEX environment variable that enables core.multiPackIndex and writes a multi-pack-index after each 'git repack' command. This adds extra test coverage when needed. There are a few spots in the test suite that need to react to this change: * t5319-multi-pack-index.sh: there is a test that checks that 'git repack' deletes the multi-pack-index. Disable the environment variable to ensure this still happens. * t5310-pack-bitmaps.sh: One test moves a pack-file from the object directory to an alternate. This breaks the multi-pack-index, so delete the multi-pack-index at this point, if it exists. * t9300-fast-import.sh: One test verifies the number of files in the .git/objects/pack directory is exactly 8. Exclude the multi-pack-index from this count so it is still 8 in all cases. Signed-off-by: Derrick Stolee Signed-off-by: Junio C Hamano --- midx.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'midx.h') diff --git a/midx.h b/midx.h index 7e60907596..228016088e 100644 --- a/midx.h +++ b/midx.h @@ -3,6 +3,8 @@ #include "repository.h" +#define GIT_TEST_MULTI_PACK_INDEX "GIT_TEST_MULTI_PACK_INDEX" + struct multi_pack_index { struct multi_pack_index *next; -- cgit v1.2.3