Skip to content

Commit 40d30d4

Browse files
derrickstoleedscho
authored andcommitted
pack-objects: enable --path-walk via config
Users may want to enable the --path-walk option for 'git pack-objects' by default, especially underneath commands like 'git push' or 'git repack'. This should be limited to client repositories, since the --path-walk option disables bitmap walks, so would be bad to include in Git servers when serving fetches and clones. There is potential that it may be helpful to consider when repacking the repository, to take advantage of improved deltas across historical versions of the same files. Much like how "pack.useSparse" was introduced and included in "feature.experimental" before being enabled by default, use the repository settings infrastructure to make the new "pack.usePathWalk" config enabled by "feature.experimental" and "feature.manyFiles". Signed-off-by: Derrick Stolee <stolee@gmail.com>
1 parent f9db153 commit 40d30d4

File tree

5 files changed

+19
-0
lines changed

5 files changed

+19
-0
lines changed

Diff for: Documentation/config/feature.txt

+4
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ walking fewer objects.
2020
+
2121
* `pack.allowPackReuse=multi` may improve the time it takes to create a pack by
2222
reusing objects from multiple packs instead of just one.
23+
+
24+
* `pack.usePathWalk` may speed up packfile creation and make the packfiles be
25+
significantly smaller in the presence of certain filename collisions with Git's
26+
default name-hash.
2327

2428
feature.manyFiles::
2529
Enable config options that optimize for repos with many files in the

Diff for: Documentation/config/pack.txt

+8
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,14 @@ pack.useSparse::
155155
commits contain certain types of direct renames. Default is
156156
`true`.
157157

158+
pack.usePathWalk::
159+
When true, git will default to using the '--path-walk' option in
160+
'git pack-objects' when the '--revs' option is present. This
161+
algorithm groups objects by path to maximize the ability to
162+
compute delta chains across historical versions of the same
163+
object. This may disable other options, such as using bitmaps to
164+
enumerate objects.
165+
158166
pack.preferBitmapTips::
159167
When selecting which commits will receive bitmaps, prefer a
160168
commit at the tip of any reference that is a suffix of any value

Diff for: builtin/pack-objects.c

+3
Original file line numberDiff line numberDiff line change
@@ -4597,6 +4597,9 @@ int cmd_pack_objects(int argc,
45974597
if (use_bitmap_index > 0 ||
45984598
!use_internal_rev_list)
45994599
path_walk = 0;
4600+
else if (the_repository->gitdir &&
4601+
the_repository->settings.pack_use_path_walk)
4602+
path_walk = 1;
46004603
else
46014604
path_walk = git_env_bool("GIT_TEST_PACK_PATH_WALK", 0);
46024605
}

Diff for: repo-settings.c

+3
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,13 @@ void prepare_repo_settings(struct repository *r)
4747
r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_SKIPPING;
4848
r->settings.pack_use_bitmap_boundary_traversal = 1;
4949
r->settings.pack_use_multi_pack_reuse = 1;
50+
r->settings.pack_use_path_walk = 1;
5051
}
5152
if (manyfiles) {
5253
r->settings.index_version = 4;
5354
r->settings.index_skip_hash = 1;
5455
r->settings.core_untracked_cache = UNTRACKED_CACHE_WRITE;
56+
r->settings.pack_use_path_walk = 1;
5557
}
5658

5759
/* Commit graph config or default, does not cascade (simple) */
@@ -66,6 +68,7 @@ void prepare_repo_settings(struct repository *r)
6668

6769
/* Boolean config or default, does not cascade (simple) */
6870
repo_cfg_bool(r, "pack.usesparse", &r->settings.pack_use_sparse, 1);
71+
repo_cfg_bool(r, "pack.usepathwalk", &r->settings.pack_use_path_walk, 0);
6972
repo_cfg_bool(r, "core.multipackindex", &r->settings.core_multi_pack_index, 1);
7073
repo_cfg_bool(r, "index.sparse", &r->settings.sparse_index, 0);
7174
repo_cfg_bool(r, "index.skiphash", &r->settings.index_skip_hash, r->settings.index_skip_hash);

Diff for: repo-settings.h

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ struct repo_settings {
5353
enum untracked_cache_setting core_untracked_cache;
5454

5555
int pack_use_sparse;
56+
int pack_use_path_walk;
5657
enum fetch_negotiation_setting fetch_negotiation_algorithm;
5758

5859
int core_multi_pack_index;

0 commit comments

Comments
 (0)