diff options
author | Russell Belfer <rb@github.com> | 2012-05-16 01:17:39 +0400 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2012-05-16 01:34:15 +0400 |
commit | 41a82592ef56a216f96558942d717af15589071d (patch) | |
tree | 8f9c2969000d388f1091b2cd134776bee59e29c6 /src/tree.h | |
parent | 54695f4098c75801f477f5bc229a52653484e08a (diff) |
Ranged iterators and rewritten git_status_file
The goal of this work is to rewrite git_status_file to use the
same underlying code as git_status_foreach.
This is done in 3 phases:
1. Extend iterators to allow ranged iteration with start and
end prefixes for the range of file names to be covered.
2. Improve diff so that when there is a pathspec and there is
a common non-wildcard prefix of the pathspec, it will use
ranged iterators to minimize excess iteration.
3. Rewrite git_status_file to call git_status_foreach_ext
with a pathspec that covers just the one file being checked.
Since ranged iterators underlie the status & diff implementation,
this is actually fairly efficient. The workdir iterator does
end up loading the contents of all the directories down to the
single file, which should ideally be avoided, but it is pretty
good.
Diffstat (limited to 'src/tree.h')
-rw-r--r-- | src/tree.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/tree.h b/src/tree.h index fd00afde5..a5b7f6323 100644 --- a/src/tree.h +++ b/src/tree.h @@ -38,4 +38,14 @@ GIT_INLINE(unsigned int) entry_is_tree(const struct git_tree_entry *e) void git_tree__free(git_tree *tree); int git_tree__parse(git_tree *tree, git_odb_object *obj); +/** + * Lookup the first position in the tree with a given prefix. + * + * @param tree a previously loaded tree. + * @param prefix the beginning of a path to find in the tree. + * @return index of the first item at or after the given prefix. + */ +int git_tree_entry_prefix_position(git_tree *tree, const char *prefix); + + #endif |