Skip to content

Commit 9fadedd

Browse files
committed
Merge branch 'ds/default-pack-use-sparse-to-true'
The 'pack.useSparse' configuration variable now defaults to 'true', enabling an optimization that has been experimental since Git 2.21. * ds/default-pack-use-sparse-to-true: pack-objects: flip the use of GIT_TEST_PACK_SPARSE config: set pack.useSparse=true by default
2 parents 3bab5d5 + 2d657ab commit 9fadedd

File tree

7 files changed

+18
-16
lines changed

7 files changed

+18
-16
lines changed

Documentation/config/feature.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,6 @@ feature.experimental::
1212
setting if you are interested in providing feedback on experimental
1313
features. The new default values are:
1414
+
15-
* `pack.useSparse=true` uses a new algorithm when constructing a pack-file
16-
which can improve `git push` performance in repos with many files.
17-
+
1815
* `fetch.negotiationAlgorithm=skipping` may improve fetch negotiation times by
1916
skipping more commits at a time, reducing the number of round trips.
2017
+

Documentation/config/pack.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,8 +119,8 @@ pack.useSparse::
119119
objects. This can have significant performance benefits when
120120
computing a pack to send a small change. However, it is possible
121121
that extra objects are added to the pack-file if the included
122-
commits contain certain types of direct renames. Default is `false`
123-
unless `feature.experimental` is enabled.
122+
commits contain certain types of direct renames. Default is
123+
`true`.
124124

125125
pack.writeBitmaps (deprecated)::
126126
This is a deprecated synonym for `repack.writeBitmaps`.

Documentation/git-pack-objects.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ SYNOPSIS
1414
[--local] [--incremental] [--window=<n>] [--depth=<n>]
1515
[--revs [--unpacked | --all]] [--keep-pack=<pack-name>]
1616
[--stdout [--filter=<filter-spec>] | base-name]
17-
[--shallow] [--keep-true-parents] [--sparse] < object-list
17+
[--shallow] [--keep-true-parents] [--[no-]sparse] < object-list
1818

1919

2020
DESCRIPTION
@@ -196,14 +196,16 @@ depth is 4095.
196196
Add --no-reuse-object if you want to force a uniform compression
197197
level on all data no matter the source.
198198

199-
--sparse::
200-
Use the "sparse" algorithm to determine which objects to include in
199+
--[no-]sparse::
200+
Toggle the "sparse" algorithm to determine which objects to include in
201201
the pack, when combined with the "--revs" option. This algorithm
202202
only walks trees that appear in paths that introduce new objects.
203203
This can have significant performance benefits when computing
204204
a pack to send a small change. However, it is possible that extra
205205
objects are added to the pack-file if the included commits contain
206-
certain types of direct renames.
206+
certain types of direct renames. If this option is not included,
207+
it defaults to the value of `pack.useSparse`, which is true unless
208+
otherwise specified.
207209

208210
--thin::
209211
Create a "thin" pack by omitting the common objects between a

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);

repo-settings.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,15 @@ void prepare_repo_settings(struct repository *r)
4545

4646
if (!repo_config_get_bool(r, "pack.usesparse", &value))
4747
r->settings.pack_use_sparse = value;
48+
UPDATE_DEFAULT_BOOL(r->settings.pack_use_sparse, 1);
49+
4850
if (!repo_config_get_bool(r, "feature.manyfiles", &value) && value) {
4951
UPDATE_DEFAULT_BOOL(r->settings.index_version, 4);
5052
UPDATE_DEFAULT_BOOL(r->settings.core_untracked_cache, UNTRACKED_CACHE_WRITE);
5153
}
5254
if (!repo_config_get_bool(r, "fetch.writecommitgraph", &value))
5355
r->settings.fetch_write_commit_graph = value;
5456
if (!repo_config_get_bool(r, "feature.experimental", &value) && value) {
55-
UPDATE_DEFAULT_BOOL(r->settings.pack_use_sparse, 1);
5657
UPDATE_DEFAULT_BOOL(r->settings.fetch_negotiation_algorithm, FETCH_NEGOTIATION_SKIPPING);
5758
UPDATE_DEFAULT_BOOL(r->settings.fetch_write_commit_graph, 1);
5859
}

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: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,16 @@ test_expect_success 'non-sparse pack-objects' '
105105
test_cmp required_objects.txt nonsparse_required_objects.txt
106106
'
107107

108+
# --sparse is enabled by default by pack.useSparse
108109
test_expect_success 'sparse pack-objects' '
110+
GIT_TEST_PACK_SPARSE=-1 &&
109111
git rev-parse \
110112
topic1 \
111113
topic1^{tree} \
112114
topic1:f3 \
113115
topic1:f3/f4 \
114116
topic1:f3/f4/data.txt | sort >expect_sparse_objects.txt &&
115-
git pack-objects --stdout --revs --sparse <packinput.txt >sparse.pack &&
117+
git pack-objects --stdout --revs <packinput.txt >sparse.pack &&
116118
git index-pack -o sparse.idx sparse.pack &&
117119
git show-index <sparse.idx | awk "{print \$2}" >sparse_objects.txt &&
118120
test_cmp expect_sparse_objects.txt sparse_objects.txt

0 commit comments

Comments
 (0)