mirror of
https://github.com/git/git.git
synced 2025-12-12 20:36:24 +01:00
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 <stolee@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
e5394794a5
commit
4705889c3d
@@ -56,6 +56,14 @@ better off using the revision walk API instead.
|
|||||||
the revision walk so that the walk emits commits marked with the
|
the revision walk so that the walk emits commits marked with the
|
||||||
`UNINTERESTING` flag.
|
`UNINTERESTING` flag.
|
||||||
|
|
||||||
|
`edge_aggressive`::
|
||||||
|
For performance reasons, usually only the boundary commits are
|
||||||
|
explored to find UNINTERESTING objects. However, in the case of
|
||||||
|
shallow clones it can be helpful to mark all trees and blobs
|
||||||
|
reachable from UNINTERESTING tip commits as UNINTERESTING. This
|
||||||
|
matches the behavior of `--objects-edge-aggressive` in the
|
||||||
|
revision API.
|
||||||
|
|
||||||
`pl`::
|
`pl`::
|
||||||
This pattern list pointer allows focusing the path-walk search to
|
This pattern list pointer allows focusing the path-walk search to
|
||||||
a set of patterns, only emitting paths that match the given
|
a set of patterns, only emitting paths that match the given
|
||||||
|
|||||||
@@ -503,7 +503,11 @@ int walk_objects_by_path(struct path_walk_info *info)
|
|||||||
if (prepare_revision_walk(info->revs))
|
if (prepare_revision_walk(info->revs))
|
||||||
die(_("failed to setup revision walk"));
|
die(_("failed to setup revision walk"));
|
||||||
|
|
||||||
/* Walk trees to mark them as UNINTERESTING. */
|
/*
|
||||||
|
* Walk trees to mark them as UNINTERESTING.
|
||||||
|
* This is particularly important when 'edge_aggressive' is set.
|
||||||
|
*/
|
||||||
|
info->revs->edge_hint_aggressive = info->edge_aggressive;
|
||||||
edge_repo = info->revs->repo;
|
edge_repo = info->revs->repo;
|
||||||
edge_tree_list = root_tree_list;
|
edge_tree_list = root_tree_list;
|
||||||
mark_edges_uninteresting(info->revs, show_edge,
|
mark_edges_uninteresting(info->revs, show_edge,
|
||||||
|
|||||||
@@ -50,6 +50,13 @@ struct path_walk_info {
|
|||||||
*/
|
*/
|
||||||
int prune_all_uninteresting;
|
int prune_all_uninteresting;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When 'edge_aggressive' is set, then the revision walk will use
|
||||||
|
* the '--object-edge-aggressive' option to mark even more objects
|
||||||
|
* as uninteresting.
|
||||||
|
*/
|
||||||
|
int edge_aggressive;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Specify a sparse-checkout definition to match our paths to. Do not
|
* Specify a sparse-checkout definition to match our paths to. Do not
|
||||||
* walk outside of this sparse definition. If the patterns are in
|
* walk outside of this sparse definition. If the patterns are in
|
||||||
|
|||||||
@@ -82,6 +82,8 @@ int cmd__path_walk(int argc, const char **argv)
|
|||||||
N_("toggle inclusion of tree objects")),
|
N_("toggle inclusion of tree objects")),
|
||||||
OPT_BOOL(0, "prune", &info.prune_all_uninteresting,
|
OPT_BOOL(0, "prune", &info.prune_all_uninteresting,
|
||||||
N_("toggle pruning of uninteresting paths")),
|
N_("toggle pruning of uninteresting paths")),
|
||||||
|
OPT_BOOL(0, "edge-aggressive", &info.edge_aggressive,
|
||||||
|
N_("toggle aggressive edge walk")),
|
||||||
OPT_BOOL(0, "stdin-pl", &stdin_pl,
|
OPT_BOOL(0, "stdin-pl", &stdin_pl,
|
||||||
N_("read a pattern list over stdin")),
|
N_("read a pattern list over stdin")),
|
||||||
OPT_END(),
|
OPT_END(),
|
||||||
|
|||||||
@@ -378,6 +378,26 @@ test_expect_success 'topic, not base, boundary with pruning' '
|
|||||||
test_cmp_sorted expect out
|
test_cmp_sorted expect out
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'topic, not base, --edge-aggressive with pruning' '
|
||||||
|
test-tool path-walk --prune --edge-aggressive -- topic --not base >out &&
|
||||||
|
|
||||||
|
cat >expect <<-EOF &&
|
||||||
|
0:commit::$(git rev-parse topic)
|
||||||
|
1:tree::$(git rev-parse topic^{tree})
|
||||||
|
1:tree::$(git rev-parse base^{tree}):UNINTERESTING
|
||||||
|
2:tree:right/:$(git rev-parse topic:right)
|
||||||
|
2:tree:right/:$(git rev-parse base:right):UNINTERESTING
|
||||||
|
3:blob:right/c:$(git rev-parse base:right/c):UNINTERESTING
|
||||||
|
3:blob:right/c:$(git rev-parse topic:right/c)
|
||||||
|
blobs:2
|
||||||
|
commits:1
|
||||||
|
tags:0
|
||||||
|
trees:4
|
||||||
|
EOF
|
||||||
|
|
||||||
|
test_cmp_sorted expect out
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'trees are reported exactly once' '
|
test_expect_success 'trees are reported exactly once' '
|
||||||
test_when_finished "rm -rf unique-trees" &&
|
test_when_finished "rm -rf unique-trees" &&
|
||||||
test_create_repo unique-trees &&
|
test_create_repo unique-trees &&
|
||||||
|
|||||||
Reference in New Issue
Block a user