Skip to content

Commit 2be08bb

Browse files
committed
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 de63133 commit 2be08bb

File tree

5 files changed

+19
-0
lines changed

5 files changed

+19
-0
lines changed

Documentation/config/feature.txt

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.txt

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
@@ -4559,6 +4559,9 @@ int cmd_pack_objects(int argc, const char **argv, const char *prefix)
45594559
if (use_bitmap_index > 0 ||
45604560
!use_internal_rev_list)
45614561
path_walk = 0;
4562+
else if (the_repository->gitdir &&
4563+
the_repository->settings.pack_use_path_walk)
4564+
path_walk = 1;
45624565
else
45634566
path_walk = git_env_bool("GIT_TEST_PACK_PATH_WALK", 0);
45644567
}

repo-settings.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ 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
/*
5253
* Force enable the builtin FSMonitor (unless the repo
@@ -76,6 +77,7 @@ void prepare_repo_settings(struct repository *r)
7677
r->settings.index_version = 4;
7778
r->settings.index_skip_hash = 1;
7879
r->settings.core_untracked_cache = UNTRACKED_CACHE_WRITE;
80+
r->settings.pack_use_path_walk = 1;
7981
}
8082

8183
/* Commit graph config or default, does not cascade (simple) */
@@ -90,6 +92,7 @@ void prepare_repo_settings(struct repository *r)
9092

9193
/* Boolean config or default, does not cascade (simple) */
9294
repo_cfg_bool(r, "pack.usesparse", &r->settings.pack_use_sparse, 1);
95+
repo_cfg_bool(r, "pack.usepathwalk", &r->settings.pack_use_path_walk, 0);
9396
repo_cfg_bool(r, "core.multipackindex", &r->settings.core_multi_pack_index, 1);
9497
repo_cfg_bool(r, "index.sparse", &r->settings.sparse_index, 0);
9598
repo_cfg_bool(r, "index.skiphash", &r->settings.index_skip_hash, r->settings.index_skip_hash);

repository.h

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

6464
int pack_use_sparse;
65+
int pack_use_path_walk;
6566
enum fetch_negotiation_setting fetch_negotiation_algorithm;
6667

6768
int core_multi_pack_index;

0 commit comments

Comments
 (0)