Skip to content

Commit 0465a50

Browse files
derrickstoleegitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1dcd9f2 commit 0465a50

File tree

7 files changed

+20
-4
lines changed

7 files changed

+20
-4
lines changed

builtin/repack.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -553,6 +553,10 @@ int cmd_repack(int argc, const char **argv, const char *prefix)
553553
if (!no_update_server_info)
554554
update_server_info(0);
555555
remove_temporary_files();
556+
557+
if (git_env_bool(GIT_TEST_MULTI_PACK_INDEX, 0))
558+
write_midx_file(get_object_directory());
559+
556560
string_list_clear(&names, 0);
557561
string_list_clear(&rollback, 0);
558562
string_list_clear(&existing_packs, 0);

midx.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,9 +338,14 @@ int prepare_multi_pack_index_one(struct repository *r, const char *object_dir, i
338338
struct multi_pack_index *m;
339339
struct multi_pack_index *m_search;
340340
int config_value;
341+
static int env_value = -1;
341342

342-
if (repo_config_get_bool(r, "core.multipackindex", &config_value) ||
343-
!config_value)
343+
if (env_value < 0)
344+
env_value = git_env_bool(GIT_TEST_MULTI_PACK_INDEX, 0);
345+
346+
if (!env_value &&
347+
(repo_config_get_bool(r, "core.multipackindex", &config_value) ||
348+
!config_value))
344349
return 0;
345350

346351
for (m_search = r->objects->multi_pack_index; m_search; m_search = m_search->next)

midx.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33

44
#include "repository.h"
55

6+
#define GIT_TEST_MULTI_PACK_INDEX "GIT_TEST_MULTI_PACK_INDEX"
7+
68
struct multi_pack_index {
79
struct multi_pack_index *next;
810

t/README

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,10 @@ GIT_TEST_COMMIT_GRAPH=<boolean>, when true, forces the commit-graph to
327327
be written after every 'git commit' command, and overrides the
328328
'core.commitGraph' setting to true.
329329

330+
GIT_TEST_MULTI_PACK_INDEX=<boolean>, when true, forces the multi-pack-
331+
index to be written after every 'git repack' command, and overrides the
332+
'core.multiPackIndex' setting to true.
333+
330334
Naming Tests
331335
------------
332336

t/t5310-pack-bitmaps.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ test_expect_success 'pack-objects respects --honor-pack-keep (local bitmapped pa
191191

192192
test_expect_success 'pack-objects respects --local (non-local bitmapped pack)' '
193193
mv .git/objects/pack/$packbitmap.* alt.git/objects/pack/ &&
194+
rm -f .git/objects/pack/multi-pack-index &&
194195
test_when_finished "mv alt.git/objects/pack/$packbitmap.* .git/objects/pack/" &&
195196
echo HEAD | git pack-objects --local --stdout --revs >3b.pack &&
196197
git index-pack 3b.pack &&

t/t5319-multi-pack-index.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ compare_results_with_midx "twelve packs"
152152

153153
test_expect_success 'repack removes multi-pack-index' '
154154
test_path_is_file $objdir/pack/multi-pack-index &&
155-
git repack -adf &&
155+
GIT_TEST_MULTI_PACK_INDEX=0 git repack -adf &&
156156
test_path_is_missing $objdir/pack/multi-pack-index
157157
'
158158

t/t9300-fast-import.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1558,7 +1558,7 @@ test_expect_success 'O: blank lines not necessary after other commands' '
15581558
INPUT_END
15591559
15601560
git fast-import <input &&
1561-
test 8 = $(find .git/objects/pack -type f | wc -l) &&
1561+
test 8 = $(find .git/objects/pack -type f | grep -v multi-pack-index | wc -l) &&
15621562
test $(git rev-parse refs/tags/O3-2nd) = $(git rev-parse O3^) &&
15631563
git log --reverse --pretty=oneline O3 | sed s/^.*z// >actual &&
15641564
test_cmp expect actual

0 commit comments

Comments
 (0)