Skip to content

Commit 4f7f571

Browse files
derrickstoleegitster
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". In order to test that this config works, add a new trace2 region around the path walk code that can be checked by a 'git push' command. Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 5f71150 commit 4f7f571

File tree

6 files changed

+32
-1
lines changed

6 files changed

+32
-1
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: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ pack.useSparse::
155155
commits contain certain types of direct renames. Default is
156156
`true`.
157157

158+
pack.usePathWalk::
159+
Enable the `--path-walk` option by default for `git pack-objects`
160+
processes. See linkgit:git-pack-objects[1] for full details.
161+
158162
pack.preferBitmapTips::
159163
When selecting which commits will receive bitmaps, prefer a
160164
commit at the tip of any reference that is a suffix of any value

builtin/pack-objects.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@
4444
#include "blob.h"
4545
#include "tree.h"
4646
#include "path-walk.h"
47+
#include "trace2.h"
4748

4849
/*
4950
* Objects we are going to pack are collected in the `to_pack` structure.
@@ -4283,6 +4284,7 @@ static void get_object_list_path_walk(struct rev_info *revs)
42834284
{
42844285
struct path_walk_info info = PATH_WALK_INFO_INIT;
42854286
unsigned int processed = 0;
4287+
int result;
42864288

42874289
info.revs = revs;
42884290
info.path_fn = add_objects_by_path;
@@ -4296,7 +4298,11 @@ static void get_object_list_path_walk(struct rev_info *revs)
42964298
*/
42974299
info.prune_all_uninteresting = sparse;
42984300

4299-
if (walk_objects_by_path(&info))
4301+
trace2_region_enter("pack-objects", "path-walk", revs->repo);
4302+
result = walk_objects_by_path(&info);
4303+
trace2_region_leave("pack-objects", "path-walk", revs->repo);
4304+
4305+
if (result)
43004306
die(_("failed to pack objects via path-walk"));
43014307
}
43024308

@@ -4652,6 +4658,9 @@ int cmd_pack_objects(int argc,
46524658
if (use_bitmap_index > 0 ||
46534659
!use_internal_rev_list)
46544660
path_walk = 0;
4661+
else if (the_repository->gitdir &&
4662+
the_repository->settings.pack_use_path_walk)
4663+
path_walk = 1;
46554664
else
46564665
path_walk = git_env_bool("GIT_TEST_PACK_PATH_WALK", 0);
46574666
}

repo-settings.c

Lines changed: 3 additions & 0 deletions
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);

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;

t/t5516-fetch-push.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1907,4 +1907,14 @@ test_expect_success 'push with config push.useBitmaps' '
19071907
--thin --delta-base-offset -q --no-use-bitmap-index <false
19081908
'
19091909

1910+
test_expect_success 'push with config pack.usePathWalk=true' '
1911+
mk_test testrepo heads/main &&
1912+
git checkout main &&
1913+
test_config pack.usePathWalk true &&
1914+
GIT_TRACE2_EVENT="$(pwd)/path-walk.txt" \
1915+
git push --quiet testrepo main:test &&
1916+
1917+
test_region pack-objects path-walk path-walk.txt
1918+
'
1919+
19101920
test_done

0 commit comments

Comments
 (0)