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 <dstolee@microsoft.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Derrick Stolee
2018-10-12 10:34:20 -07:00
committed by Junio C Hamano
parent 1dcd9f2043
commit 0465a50506
7 changed files with 20 additions and 4 deletions

9
midx.c
View File

@ -338,9 +338,14 @@ int prepare_multi_pack_index_one(struct repository *r, const char *object_dir, i
struct multi_pack_index *m;
struct multi_pack_index *m_search;
int config_value;
static int env_value = -1;
if (repo_config_get_bool(r, "core.multipackindex", &config_value) ||
!config_value)
if (env_value < 0)
env_value = git_env_bool(GIT_TEST_MULTI_PACK_INDEX, 0);
if (!env_value &&
(repo_config_get_bool(r, "core.multipackindex", &config_value) ||
!config_value))
return 0;
for (m_search = r->objects->multi_pack_index; m_search; m_search = m_search->next)