Skip to content

Commit 99dbbfa

Browse files
derrickstoleegitster
authored andcommitted
pack-objects: create GIT_TEST_PACK_SPARSE
Create a test variable GIT_TEST_PACK_SPARSE to enable the sparse object walk algorithm by default during the test suite. Enabling this variable ensures coverage in many interesting cases, such as shallow clones, partial clones, and missing objects. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 3d036eb commit 99dbbfa

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

builtin/pack-objects.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3331,6 +3331,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
33313331

33323332
read_replace_refs = 0;
33333333

3334+
sparse = git_env_bool("GIT_TEST_PACK_SPARSE", 0);
33343335
reset_pack_idx_option(&pack_idx_opts);
33353336
git_config(git_pack_config, NULL);
33363337

t/README

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,10 @@ GIT_TEST_INDEX_VERSION=<n> exercises the index read/write code path
342342
for the index version specified. Can be set to any valid version
343343
(currently 2, 3, or 4).
344344

345+
GIT_TEST_PACK_SPARSE=<boolean> if enabled will default the pack-objects
346+
builtin to use the sparse object walk. This can still be overridden by
347+
the --no-sparse command-line argument.
348+
345349
GIT_TEST_PRELOAD_INDEX=<boolean> exercises the preload-index code path
346350
by overriding the minimum number of cache entries required per thread.
347351

t/t5322-pack-objects-sparse.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ test_expect_success 'setup repo' '
3636
'
3737

3838
test_expect_success 'non-sparse pack-objects' '
39-
git pack-objects --stdout --revs <packinput.txt >nonsparse.pack &&
39+
git pack-objects --stdout --revs --no-sparse <packinput.txt >nonsparse.pack &&
4040
git index-pack -o nonsparse.idx nonsparse.pack &&
4141
git show-index <nonsparse.idx | awk "{print \$2}" >nonsparse_objects.txt &&
4242
test_cmp expect_objects.txt nonsparse_objects.txt
@@ -64,7 +64,7 @@ test_expect_success 'duplicate a folder from f3 and commit to topic1' '
6464
'
6565

6666
test_expect_success 'non-sparse pack-objects' '
67-
git pack-objects --stdout --revs <packinput.txt >nonsparse.pack &&
67+
git pack-objects --stdout --revs --no-sparse <packinput.txt >nonsparse.pack &&
6868
git index-pack -o nonsparse.idx nonsparse.pack &&
6969
git show-index <nonsparse.idx | awk "{print \$2}" >nonsparse_objects.txt &&
7070
comm -1 -2 required_objects.txt nonsparse_objects.txt >nonsparse_required_objects.txt &&

0 commit comments

Comments
 (0)