Skip to content

Commit 2d657ab

Browse files
derrickstoleegitster
authored andcommitted
pack-objects: flip the use of GIT_TEST_PACK_SPARSE
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent de3a864 commit 2d657ab

File tree

3 files changed

+6
-5
lines changed

3 files changed

+6
-5
lines changed

builtin/pack-objects.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3469,9 +3469,9 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
34693469

34703470
read_replace_refs = 0;
34713471

3472-
sparse = git_env_bool("GIT_TEST_PACK_SPARSE", 0);
3472+
sparse = git_env_bool("GIT_TEST_PACK_SPARSE", -1);
34733473
prepare_repo_settings(the_repository);
3474-
if (!sparse && the_repository->settings.pack_use_sparse != -1)
3474+
if (sparse < 0)
34753475
sparse = the_repository->settings.pack_use_sparse;
34763476

34773477
reset_pack_idx_option(&pack_idx_opts);

t/README

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -386,9 +386,9 @@ GIT_TEST_INDEX_VERSION=<n> exercises the index read/write code path
386386
for the index version specified. Can be set to any valid version
387387
(currently 2, 3, or 4).
388388

389-
GIT_TEST_PACK_SPARSE=<boolean> if enabled will default the pack-objects
390-
builtin to use the sparse object walk. This can still be overridden by
391-
the --no-sparse command-line argument.
389+
GIT_TEST_PACK_SPARSE=<boolean> if disabled will default the pack-objects
390+
builtin to use the non-sparse object walk. This can still be overridden by
391+
the --sparse command-line argument.
392392

393393
GIT_TEST_PRELOAD_INDEX=<boolean> exercises the preload-index code path
394394
by overriding the minimum number of cache entries required per thread.

t/t5322-pack-objects-sparse.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ test_expect_success 'non-sparse pack-objects' '
107107

108108
# --sparse is enabled by default by pack.useSparse
109109
test_expect_success 'sparse pack-objects' '
110+
GIT_TEST_PACK_SPARSE=-1 &&
110111
git rev-parse \
111112
topic1 \
112113
topic1^{tree} \

0 commit comments

Comments
 (0)