Skip to content

Commit 91e6ceb

Browse files
derrickstoleeGit for Windows Build Agent
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 <[email protected]>
1 parent 9c265df commit 91e6ceb

File tree

5 files changed

+19
-0
lines changed

5 files changed

+19
-0
lines changed

Documentation/config/feature.adoc

Lines changed: 4 additions & 0 deletions
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

Documentation/config/pack.adoc

Lines changed: 8 additions & 0 deletions
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

builtin/pack-objects.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4732,6 +4732,9 @@ int cmd_pack_objects(int argc,
47324732
if (use_bitmap_index > 0 ||
47334733
!use_internal_rev_list)
47344734
path_walk = 0;
4735+
else if (the_repository->gitdir &&
4736+
the_repository->settings.pack_use_path_walk)
4737+
path_walk = 1;
47354738
else
47364739
path_walk = git_env_bool("GIT_TEST_PACK_PATH_WALK", 0);
47374740
}

repo-settings.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,11 +54,13 @@ void prepare_repo_settings(struct repository *r)
5454
r->settings.fetch_negotiation_algorithm = FETCH_NEGOTIATION_SKIPPING;
5555
r->settings.pack_use_bitmap_boundary_traversal = 1;
5656
r->settings.pack_use_multi_pack_reuse = 1;
57+
r->settings.pack_use_path_walk = 1;
5758
}
5859
if (manyfiles) {
5960
r->settings.index_version = 4;
6061
r->settings.index_skip_hash = 1;
6162
r->settings.core_untracked_cache = UNTRACKED_CACHE_WRITE;
63+
r->settings.pack_use_path_walk = 1;
6264
}
6365

6466
/* Commit graph config or default, does not cascade (simple) */
@@ -73,6 +75,7 @@ void prepare_repo_settings(struct repository *r)
7375

7476
/* Boolean config or default, does not cascade (simple) */
7577
repo_cfg_bool(r, "pack.usesparse", &r->settings.pack_use_sparse, 1);
78+
repo_cfg_bool(r, "pack.usepathwalk", &r->settings.pack_use_path_walk, 0);
7679
repo_cfg_bool(r, "core.multipackindex", &r->settings.core_multi_pack_index, 1);
7780
repo_cfg_bool(r, "index.sparse", &r->settings.sparse_index, 0);
7881
repo_cfg_bool(r, "index.skiphash", &r->settings.index_skip_hash, r->settings.index_skip_hash);

repo-settings.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ struct repo_settings {
5656
enum untracked_cache_setting core_untracked_cache;
5757

5858
int pack_use_sparse;
59+
int pack_use_path_walk;
5960
enum fetch_negotiation_setting fetch_negotiation_algorithm;
6061

6162
int core_multi_pack_index;

0 commit comments

Comments
 (0)