Skip to content

Commit 2d190b0

Browse files
derrickstoleedscho
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. We didn't use this in the past because we would mark objects UNINTERESTING after doing the initial commit walk to the boundary. While we should be marking these objects as UNINTERESTING, we shouldn't _emit_ them all via the path-walk algorithm or else our delta calculations will get really slow. Based on these observations, the way we were handling the UNINTERESTING flag in walk_objects_by_path() was overly complicated and buggy. A lot of it can be removed and simplified to work with this new approach. It also means that we will see the UNINTERESTING boundaries of paths when doing a default path-walk call, changing some existing test cases. Signed-off-by: Derrick Stolee <[email protected]>
1 parent 43e5af3 commit 2d190b0

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-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

0 commit comments

Comments
 (0)