Skip to content

Commit d011a9c

Browse files
committed
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>
1 parent f386f6c commit d011a9c

3 files changed

Lines changed: 8 additions & 3 deletions

File tree

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: 3 additions & 3 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
@@ -70,7 +70,7 @@ test_expect_success 'duplicate a folder from f3 and commit to topic1' '
7070
'
7171

7272
test_expect_success 'non-sparse pack-objects' '
73-
git pack-objects --stdout --revs <packinput.txt >nonsparse.pack &&
73+
git pack-objects --stdout --revs --no-sparse <packinput.txt >nonsparse.pack &&
7474
git index-pack -o nonsparse.idx nonsparse.pack &&
7575
git show-index <nonsparse.idx | awk "{print \$2}" >nonsparse_objects.txt &&
7676
test_cmp expect_objects.txt nonsparse_objects.txt
@@ -102,7 +102,7 @@ test_expect_success 'non-sparse pack-objects' '
102102
topic1 \
103103
topic1^{tree} \
104104
topic1:f3 | sort >expect_objects.txt &&
105-
git pack-objects --stdout --revs <packinput.txt >nonsparse.pack &&
105+
git pack-objects --stdout --revs --no-sparse <packinput.txt >nonsparse.pack &&
106106
git index-pack -o nonsparse.idx nonsparse.pack &&
107107
git show-index <nonsparse.idx | awk "{print \$2}" >nonsparse_objects.txt &&
108108
test_cmp expect_objects.txt nonsparse_objects.txt

0 commit comments

Comments
 (0)