Skip to content

Commit 6201afe

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". 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 0d088ce commit 6201afe

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.
@@ -4362,6 +4363,7 @@ static void get_object_list_path_walk(struct rev_info *revs)
43624363
{
43634364
struct path_walk_info info = PATH_WALK_INFO_INIT;
43644365
unsigned int processed = 0;
4366+
int result;
43654367

43664368
info.revs = revs;
43674369
info.path_fn = add_objects_by_path;
@@ -4376,7 +4378,11 @@ static void get_object_list_path_walk(struct rev_info *revs)
43764378
*/
43774379
info.prune_all_uninteresting = sparse;
43784380

4379-
if (walk_objects_by_path(&info))
4381+
trace2_region_enter("pack-objects", "path-walk", revs->repo);
4382+
result = walk_objects_by_path(&info);
4383+
trace2_region_leave("pack-objects", "path-walk", revs->repo);
4384+
4385+
if (result)
43804386
die(_("failed to pack objects via path-walk"));
43814387
}
43824388

@@ -4732,6 +4738,9 @@ int cmd_pack_objects(int argc,
47324738
if (use_bitmap_index > 0 ||
47334739
!use_internal_rev_list)
47344740
path_walk = 0;
4741+
else if (the_repository->gitdir &&
4742+
the_repository->settings.pack_use_path_walk)
4743+
path_walk = 1;
47354744
else
47364745
path_walk = git_env_bool("GIT_TEST_PACK_PATH_WALK", 0);
47374746
}

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;

t/t5516-fetch-push.sh

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

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

0 commit comments

Comments
 (0)