Skip to content

Commit 2bb6b3d

Browse files
derrickstoleeGit for Windows Build Agent
authored and
Git for Windows Build Agent
committed
Add path walk API and its use in 'git pack-objects' (#5171)
This is a follow up to #5157 as well as motivated by the RFC in gitgitgadget#1786. We have ways of walking all objects, but it is focused on visiting a single commit and then expanding the new trees and blobs reachable from that commit that have not been visited yet. This means that objects arrive without any locality based on their path. Add a new "path walk API" that focuses on walking objects in batches according to their type and path. This will walk all annotated tags, all commits, all root trees, and then start a depth-first search among all paths in the repo to collect trees and blobs in batches. The most important application for this is being fast-tracked to Git for Windows: `git pack-objects --path-walk`. This application of the path walk API discovers the objects to pack via this batched walk, and automatically groups objects that appear at a common path so they can be checked for delta comparisons. This use completely avoids any name-hash collisions (even the collisions that sometimes occur with the new `--full-name-hash` option) and can be much faster to compute since the first pass of delta calculations does not waste time on objects that are unlikely to be diffable. Some statistics are available in the commit messages.
2 parents 543103d + 3f63ff0 commit 2bb6b3d

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

revision.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,21 @@ static void add_children_by_path(struct repository *r,
212212
free_tree_buffer(tree);
213213
}
214214

215+
void mark_trees_uninteresting_dense(struct repository *r,
216+
struct oidset *trees)
217+
{
218+
struct object_id *oid;
219+
struct oidset_iter iter;
220+
221+
oidset_iter_init(trees, &iter);
222+
while ((oid = oidset_iter_next(&iter))) {
223+
struct tree *tree = lookup_tree(r, oid);
224+
225+
if (tree->object.flags & UNINTERESTING)
226+
mark_tree_contents_uninteresting(r, tree);
227+
}
228+
}
229+
215230
void mark_trees_uninteresting_sparse(struct repository *r,
216231
struct oidset *trees)
217232
{

revision.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,7 @@ void put_revision_mark(const struct rev_info *revs,
486486

487487
void mark_parents_uninteresting(struct rev_info *revs, struct commit *commit);
488488
void mark_tree_uninteresting(struct repository *r, struct tree *tree);
489+
void mark_trees_uninteresting_dense(struct repository *r, struct oidset *trees);
489490
void mark_trees_uninteresting_sparse(struct repository *r, struct oidset *trees);
490491

491492
/**

0 commit comments

Comments
 (0)