pack-objects: create GIT_TEST_PACK_SPARSE
authorDerrick Stolee <dstolee@microsoft.com>
Wed, 16 Jan 2019 18:26:01 +0000 (10:26 -0800)
committerJunio C Hamano <gitster@pobox.com>
Thu, 17 Jan 2019 21:44:44 +0000 (13:44 -0800)
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>
builtin/pack-objects.c
t/README
t/t5322-pack-objects-sparse.sh
index 124b1bafc4b892466d20ec38ac3a2f8a5b81eac0..507d381153511d52dac88f144a5887d0536c10d4 100644 (file)
@@ -3331,6 +3331,7 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
 
        read_replace_refs = 0;
 
+       sparse = git_env_bool("GIT_TEST_PACK_SPARSE", 0);
        reset_pack_idx_option(&pack_idx_opts);
        git_config(git_pack_config, NULL);
 
index 28711cc508f9e5dfb2f2ef238be14926d56f9a12..8b6dfe1864d2307560c8785aac6cace8addafb91 100644 (file)
--- a/t/README
+++ b/t/README
@@ -342,6 +342,10 @@ GIT_TEST_INDEX_VERSION=<n> exercises the index read/write code path
 for the index version specified.  Can be set to any valid version
 (currently 2, 3, or 4).
 
+GIT_TEST_PACK_SPARSE=<boolean> if enabled will default the pack-objects
+builtin to use the sparse object walk. This can still be overridden by
+the --no-sparse command-line argument.
+
 GIT_TEST_PRELOAD_INDEX=<boolean> exercises the preload-index code path
 by overriding the minimum number of cache entries required per thread.
 
index 3233fafc90b02ee5c5578984e28d73ec70af7990..7124b5581a0e3e31ae9b78b46aec9f059eeb7c1a 100755 (executable)
@@ -36,7 +36,7 @@ test_expect_success 'setup repo' '
 '
 
 test_expect_success 'non-sparse pack-objects' '
-       git pack-objects --stdout --revs <packinput.txt >nonsparse.pack &&
+       git pack-objects --stdout --revs --no-sparse <packinput.txt >nonsparse.pack &&
        git index-pack -o nonsparse.idx nonsparse.pack &&
        git show-index <nonsparse.idx | awk "{print \$2}" >nonsparse_objects.txt &&
        test_cmp expect_objects.txt nonsparse_objects.txt
@@ -64,7 +64,7 @@ test_expect_success 'duplicate a folder from f3 and commit to topic1' '
 '
 
 test_expect_success 'non-sparse pack-objects' '
-       git pack-objects --stdout --revs <packinput.txt >nonsparse.pack &&
+       git pack-objects --stdout --revs --no-sparse <packinput.txt >nonsparse.pack &&
        git index-pack -o nonsparse.idx nonsparse.pack &&
        git show-index <nonsparse.idx | awk "{print \$2}" >nonsparse_objects.txt &&
        comm -1 -2 required_objects.txt nonsparse_objects.txt >nonsparse_required_objects.txt &&