Skip to content

Commit

Permalink
revision: create mark_trees_uninteresting_dense()
Browse files Browse the repository at this point in the history
The sparse tree walk algorithm was created in d5d2e93 (revision:
implement sparse algorithm, 2019-01-16) and involves using the
mark_trees_uninteresting_sparse() method. This method takes a repository
and an oidset of tree IDs, some of which have the UNINTERESTING flag and
some of which do not.

Create a method that has an equivalent set of preconditions but uses a
"dense" walk (recursively visits all reachable trees, as long as they
have not previously been marked UNINTERESTING). This is an important
difference from mark_tree_uninteresting(), which short-circuits if the
given tree has the UNINTERESTING flag.

A use of this method will be added in a later change, with a condition
set whether the sparse or dense approach should be used.

Signed-off-by: Derrick Stolee <[email protected]>
  • Loading branch information
derrickstolee authored and dscho committed Jan 11, 2025
1 parent a3d393b commit e35f96d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions revision.c
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,21 @@ static void add_children_by_path(struct repository *r,
free_tree_buffer(tree);
}

void mark_trees_uninteresting_dense(struct repository *r,
struct oidset *trees)
{
struct object_id *oid;
struct oidset_iter iter;

oidset_iter_init(trees, &iter);
while ((oid = oidset_iter_next(&iter))) {
struct tree *tree = lookup_tree(r, oid);

if (tree->object.flags & UNINTERESTING)
mark_tree_contents_uninteresting(r, tree);
}
}

void mark_trees_uninteresting_sparse(struct repository *r,
struct oidset *trees)
{
Expand Down
1 change: 1 addition & 0 deletions revision.h
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@ void put_revision_mark(const struct rev_info *revs,

void mark_parents_uninteresting(struct rev_info *revs, struct commit *commit);
void mark_tree_uninteresting(struct repository *r, struct tree *tree);
void mark_trees_uninteresting_dense(struct repository *r, struct oidset *trees);
void mark_trees_uninteresting_sparse(struct repository *r, struct oidset *trees);

void show_object_with_name(FILE *, struct object *, const char *);
Expand Down

0 comments on commit e35f96d

Please sign in to comment.