]> git.ipfire.org Git - thirdparty/git.git/commitdiff
pack-objects: flip the use of GIT_TEST_PACK_SPARSE
authorDerrick Stolee <dstolee@microsoft.com>
Fri, 20 Mar 2020 12:38:10 +0000 (12:38 +0000)
committerJunio C Hamano <gitster@pobox.com>
Fri, 20 Mar 2020 21:22:32 +0000 (14:22 -0700)
The environment variable GIT_TEST_PACK_SPARSE was previously used
to allow testing the --sparse option for "git pack-objects" in
the test suite. This allowed interesting cases of "git push" to
also test this algorithm.

Since pack.useSparse is now true by default, we do not need this
variable to _enable_ the --sparse option, but instead to _disable_
it. This flips how we work with the variable a bit.

When checking for the variable, default to a value of -1 for
"unset". If unset, then take the default from the repo settings,
which is currently 1. Then, the --[no-]sparse command-line option
will override either of these settings.

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 02aa6ee4808a96f264a861bc49789341179056be..eff9542f09ff1115c572a729ba8b4a2eb684376a 100644 (file)
@@ -3469,9 +3469,9 @@ 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);
+       sparse = git_env_bool("GIT_TEST_PACK_SPARSE", -1);
        prepare_repo_settings(the_repository);
-       if (!sparse && the_repository->settings.pack_use_sparse != -1)
+       if (sparse < 0)
                sparse = the_repository->settings.pack_use_sparse;
 
        reset_pack_idx_option(&pack_idx_opts);
index 9afd61e3ca0d19e569c5d31855fbbc79c83c9d4e..99ebb18829f9d5d2d0366b7339f1f7bdd4b72f93 100644 (file)
--- a/t/README
+++ b/t/README
@@ -386,9 +386,9 @@ 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_PACK_SPARSE=<boolean> if disabled will default the pack-objects
+builtin to use the non-sparse object walk. This can still be overridden by
+the --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 6e5d6bdb0a738743c19d0c7a8de2656740f054fb..a581eaf52936292f28b2ff9542bccd8f2ea5152a 100755 (executable)
@@ -107,6 +107,7 @@ test_expect_success 'non-sparse pack-objects' '
 
 # --sparse is enabled by default by pack.useSparse
 test_expect_success 'sparse pack-objects' '
+       GIT_TEST_PACK_SPARSE=-1 &&
        git rev-parse                   \
                topic1                  \
                topic1^{tree}           \