Skip to content

Commit 817e30a

Browse files
committed
revision: add mark_tree_uninteresting_sparse
In preparation for a new algorithm that walks fewer trees when creating a pack from a set of revisions, create a method that takes an oidset of tree oids and marks reachable objects as UNINTERESTING. The current implementation uses the existing mark_tree_uninteresting to recursively walk the trees and blobs. This will walk the same number of trees as the old mechanism. There is one new assumption in this approach: we are also given the oids of the interesting trees. This implementation does not use those trees at the moment, but we will use them in a later rewrite of this method. Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
1 parent a159801 commit 817e30a

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

revision.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,31 @@ void mark_tree_uninteresting(struct repository *r, struct tree *tree)
9999
mark_tree_contents_uninteresting(r, tree);
100100
}
101101

102+
void mark_trees_uninteresting_sparse(struct repository *r,
103+
struct oidset *set)
104+
{
105+
struct object_id *oid;
106+
struct oidset_iter iter;
107+
108+
oidset_iter_init(set, &iter);
109+
while ((oid = oidset_iter_next(&iter))) {
110+
struct tree *tree = lookup_tree(r, oid);
111+
112+
if (!tree)
113+
continue;
114+
115+
if (tree->object.flags & UNINTERESTING) {
116+
/*
117+
* Remove the flag so the next call
118+
* is not a no-op. The flag is added
119+
* in mark_tree_unintersting().
120+
*/
121+
tree->object.flags ^= UNINTERESTING;
122+
mark_tree_uninteresting(r, tree);
123+
}
124+
}
125+
}
126+
102127
struct commit_stack {
103128
struct commit **items;
104129
size_t nr, alloc;

revision.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ struct rev_cmdline_info {
6767
#define REVISION_WALK_NO_WALK_SORTED 1
6868
#define REVISION_WALK_NO_WALK_UNSORTED 2
6969

70+
struct oidset;
7071
struct topo_walk_info;
7172

7273
struct rev_info {
@@ -327,6 +328,7 @@ void put_revision_mark(const struct rev_info *revs,
327328

328329
void mark_parents_uninteresting(struct commit *commit);
329330
void mark_tree_uninteresting(struct repository *r, struct tree *tree);
331+
void mark_trees_uninteresting_sparse(struct repository *r, struct oidset *set);
330332

331333
void show_object_with_name(FILE *, struct object *, const char *);
332334

0 commit comments

Comments
 (0)