Skip to content

Commit d5ee425

Browse files
dschoGit for Windows Build Agent
authored andcommitted
Replace experimental path walk feature with upstream version (#5689)
This reverts the experimental version of the `git repack --path-walk` feature and replaces it with the version that recently merged with upstream. It includes `fixup!` commits for the reverts of the previous feature for easy reduction in the branch thicket during the 2.51.0 release window. > Note: In the current version, I have not performed any local validation, only resolved one text merge conflict.
2 parents c06ed0e + 1b2bcbb commit d5ee425

File tree

8 files changed

+107
-44
lines changed

8 files changed

+107
-44
lines changed

Documentation/technical/api-path-walk.adoc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ better off using the revision walk API instead.
5656
the revision walk so that the walk emits commits marked with the
5757
`UNINTERESTING` flag.
5858

59+
`edge_aggressive`::
60+
For performance reasons, usually only the boundary commits are
61+
explored to find UNINTERESTING objects. However, in the case of
62+
shallow clones it can be helpful to mark all trees and blobs
63+
reachable from UNINTERESTING tip commits as UNINTERESTING. This
64+
matches the behavior of `--objects-edge-aggressive` in the
65+
revision API.
66+
5967
`pl`::
6068
This pattern list pointer allows focusing the path-walk search to
6169
a set of patterns, only emitting paths that match the given

builtin/pack-objects.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ static int keep_unreachable, unpack_unreachable, include_tag;
204204
static timestamp_t unpack_unreachable_expiration;
205205
static int pack_loose_unreachable;
206206
static int cruft;
207+
static int shallow = 0;
207208
static timestamp_t cruft_expiration;
208209
static int local;
209210
static int have_non_local_packs;
@@ -4568,6 +4569,7 @@ static void get_object_list_path_walk(struct rev_info *revs)
45684569
* base objects.
45694570
*/
45704571
info.prune_all_uninteresting = sparse;
4572+
info.edge_aggressive = shallow;
45714573

45724574
trace2_region_enter("pack-objects", "path-walk", revs->repo);
45734575
result = walk_objects_by_path(&info);
@@ -4773,7 +4775,6 @@ int cmd_pack_objects(int argc,
47734775
struct repository *repo UNUSED)
47744776
{
47754777
int use_internal_rev_list = 0;
4776-
int shallow = 0;
47774778
int all_progress_implied = 0;
47784779
struct strvec rp = STRVEC_INIT;
47794780
int rev_list_unpacked = 0, rev_list_all = 0, rev_list_reflog = 0;
@@ -4961,10 +4962,6 @@ int cmd_pack_objects(int argc,
49614962
warning(_("cannot use delta islands with --path-walk"));
49624963
path_walk = 0;
49634964
}
4964-
if (path_walk && shallow) {
4965-
warning(_("cannot use --shallow with --path-walk"));
4966-
path_walk = 0;
4967-
}
49684965
if (path_walk) {
49694966
strvec_push(&rp, "--boundary");
49704967
/*

path-walk.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -503,7 +503,11 @@ int walk_objects_by_path(struct path_walk_info *info)
503503
if (prepare_revision_walk(info->revs))
504504
die(_("failed to setup revision walk"));
505505

506-
/* Walk trees to mark them as UNINTERESTING. */
506+
/*
507+
* Walk trees to mark them as UNINTERESTING.
508+
* This is particularly important when 'edge_aggressive' is set.
509+
*/
510+
info->revs->edge_hint_aggressive = info->edge_aggressive;
507511
edge_repo = info->revs->repo;
508512
edge_tree_list = root_tree_list;
509513
mark_edges_uninteresting(info->revs, show_edge,

path-walk.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ struct path_walk_info {
5050
*/
5151
int prune_all_uninteresting;
5252

53+
/**
54+
* When 'edge_aggressive' is set, then the revision walk will use
55+
* the '--object-edge-aggressive' option to mark even more objects
56+
* as uninteresting.
57+
*/
58+
int edge_aggressive;
59+
5360
/**
5461
* Specify a sparse-checkout definition to match our paths to. Do not
5562
* walk outside of this sparse definition. If the patterns are in

t/helper/test-path-walk.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ int cmd__path_walk(int argc, const char **argv)
8282
N_("toggle inclusion of tree objects")),
8383
OPT_BOOL(0, "prune", &info.prune_all_uninteresting,
8484
N_("toggle pruning of uninteresting paths")),
85+
OPT_BOOL(0, "edge-aggressive", &info.edge_aggressive,
86+
N_("toggle aggressive edge walk")),
8587
OPT_BOOL(0, "stdin-pl", &stdin_pl,
8688
N_("read a pattern list over stdin")),
8789
OPT_END(),

t/perf/p5313-pack-objects.sh

Lines changed: 22 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -22,71 +22,55 @@ test_expect_success 'create rev input' '
2222
EOF
2323
'
2424

25-
for version in 1 2
26-
do
27-
export version
25+
test_all_with_args () {
26+
parameter=$1
27+
export parameter
2828

29-
test_perf "thin pack with version $version" '
29+
test_perf "thin pack with $parameter" '
3030
git pack-objects --thin --stdout --revs --sparse \
31-
--name-hash-version=$version <in-thin >out
31+
$parameter <in-thin >out
3232
'
3333

34-
test_size "thin pack size with version $version" '
34+
test_size "thin pack size with $parameter" '
3535
test_file_size out
3636
'
3737

38-
test_perf "big pack with version $version" '
38+
test_perf "big pack with $parameter" '
3939
git pack-objects --stdout --revs --sparse \
40-
--name-hash-version=$version <in-big >out
40+
$parameter <in-big >out
4141
'
4242

43-
test_size "big pack size with version $version" '
43+
test_size "big pack size with $parameter" '
4444
test_file_size out
4545
'
4646

47-
test_perf "shallow fetch pack with version $version" '
47+
test_perf "shallow fetch pack with $parameter" '
4848
git pack-objects --stdout --revs --sparse --shallow \
49-
--name-hash-version=$version <in-shallow >out
49+
$parameter <in-shallow >out
5050
'
5151

52-
test_size "shallow pack size with version $version" '
52+
test_size "shallow pack size with $parameter" '
5353
test_file_size out
5454
'
55+
}
56+
57+
for version in 1 2
58+
do
59+
export version
60+
61+
test_all_with_args --name-hash-version=$version
5562

56-
test_perf "repack with version $version" '
63+
test_perf "repack with --name-hash-version=$version" '
5764
git repack -adf --name-hash-version=$version
5865
'
5966

60-
test_size "repack size with version $version" '
67+
test_size "repack size with --name-hash-version=$version" '
6168
gitdir=$(git rev-parse --git-dir) &&
6269
pack=$(ls $gitdir/objects/pack/pack-*.pack) &&
6370
test_file_size "$pack"
6471
'
6572
done
6673

67-
test_perf 'thin pack with --path-walk' '
68-
git pack-objects --thin --stdout --revs --sparse --path-walk <in-thin >out
69-
'
70-
71-
test_size 'thin pack size with --path-walk' '
72-
test_file_size out
73-
'
74-
75-
test_perf 'big pack with --path-walk' '
76-
git pack-objects --stdout --revs --sparse --path-walk <in-big >out
77-
'
78-
79-
test_size 'big pack size with --path-walk' '
80-
test_file_size out
81-
'
82-
83-
test_perf 'repack with --path-walk' '
84-
git repack -adf --path-walk
85-
'
86-
87-
test_size 'repack size with --path-walk' '
88-
pack=$(ls .git/objects/pack/pack-*.pack) &&
89-
test_file_size "$pack"
90-
'
74+
test_all_with_args --path-walk
9175

9276
test_done

t/t5538-push-shallow.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,4 +123,45 @@ EOF
123123
git cat-file blob $(echo 1|git hash-object --stdin) >/dev/null
124124
)
125125
'
126+
127+
test_expect_success 'push new commit from shallow clone has correct object count' '
128+
git init origin &&
129+
test_commit -C origin a &&
130+
test_commit -C origin b &&
131+
132+
git clone --depth=1 "file://$(pwd)/origin" client &&
133+
git -C client checkout -b topic &&
134+
git -C client commit --allow-empty -m "empty" &&
135+
GIT_PROGRESS_DELAY=0 git -C client push --progress origin topic 2>err &&
136+
test_grep "Enumerating objects: 1, done." err
137+
'
138+
139+
test_expect_success 'push new commit from shallow clone has good deltas' '
140+
git init base &&
141+
test_seq 1 999 >base/a &&
142+
test_commit -C base initial &&
143+
git -C base add a &&
144+
git -C base commit -m "big a" &&
145+
146+
git clone --depth=1 "file://$(pwd)/base" deltas &&
147+
git -C deltas checkout -b deltas &&
148+
test_seq 1 1000 >deltas/a &&
149+
git -C deltas commit -a -m "bigger a" &&
150+
GIT_PROGRESS_DELAY=0 git -C deltas push --progress origin deltas 2>err &&
151+
152+
test_grep "Enumerating objects: 5, done" err &&
153+
154+
# If the delta base is found, then this message uses "bytes".
155+
# If the delta base is not found, then this message uses "KiB".
156+
test_grep "Writing objects: .* bytes" err &&
157+
158+
git -C deltas commit --amend -m "changed message" &&
159+
GIT_TRACE2_EVENT="$(pwd)/config-push.txt" \
160+
GIT_PROGRESS_DELAY=0 git -C deltas -c pack.usePathWalk=true \
161+
push --progress -f origin deltas 2>err &&
162+
163+
test_grep "Enumerating objects: 1, done" err &&
164+
test_region pack-objects path-walk config-push.txt
165+
'
166+
126167
test_done

t/t6601-path-walk.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,26 @@ test_expect_success 'topic, not base, boundary with pruning' '
376376
test_cmp_sorted expect out
377377
'
378378

379+
test_expect_success 'topic, not base, --edge-aggressive with pruning' '
380+
test-tool path-walk --prune --edge-aggressive -- topic --not base >out &&
381+
382+
cat >expect <<-EOF &&
383+
0:commit::$(git rev-parse topic)
384+
1:tree::$(git rev-parse topic^{tree})
385+
1:tree::$(git rev-parse base^{tree}):UNINTERESTING
386+
2:tree:right/:$(git rev-parse topic:right)
387+
2:tree:right/:$(git rev-parse base:right):UNINTERESTING
388+
3:blob:right/c:$(git rev-parse base:right/c):UNINTERESTING
389+
3:blob:right/c:$(git rev-parse topic:right/c)
390+
blobs:2
391+
commits:1
392+
tags:0
393+
trees:4
394+
EOF
395+
396+
test_cmp_sorted expect out
397+
'
398+
379399
test_expect_success 'trees are reported exactly once' '
380400
test_when_finished "rm -rf unique-trees" &&
381401
test_create_repo unique-trees &&

0 commit comments

Comments
 (0)