Skip to content

Commit 4705889

Browse files
derrickstoleegitster
authored andcommitted
path-walk: add new 'edge_aggressive' option
In preparation for allowing both the --shallow and --path-walk options in the 'git pack-objects' builtin, create a new 'edge_aggressive' option in the path-walk API. This option will help walk the boundary more thoroughly and help avoid sending extra objects during fetches and pushes. The only use of the 'edge_hint_aggressive' option in the revision API is within mark_edges_uninteresting(), which is usually called before between prepare_revision_walk() and before visiting commits with get_revision(). In prepare_revision_walk(), the UNINTERESTING commits are walked until a boundary is found. Signed-off-by: Derrick Stolee <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e539479 commit 4705889

File tree

5 files changed

+42
-1
lines changed

5 files changed

+42
-1
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

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/t6601-path-walk.sh

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

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

0 commit comments

Comments
 (0)