diff options
author | Edward Thomson <ethomson@edwardthomson.com> | 2015-08-30 18:35:57 -0400 |
---|---|---|
committer | Edward Thomson <ethomson@edwardthomson.com> | 2015-08-30 18:55:18 -0400 |
commit | 1af84271dd221343bc199207f3eb923781124928 (patch) | |
tree | 43c3ac782b508b4e0d4a21e3aa143459e73c65bf /src/iterator.c | |
parent | 4a0dbeb0d35343ded24b51906f2a8f8ef6c7910b (diff) | |
download | libgit2-1af84271dd221343bc199207f3eb923781124928.tar.gz |
tree_iterator: use a pathlist
Diffstat (limited to 'src/iterator.c')
-rw-r--r-- | src/iterator.c | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/src/iterator.c b/src/iterator.c index bad24d13e..9bf56b650 100644 --- a/src/iterator.c +++ b/src/iterator.c @@ -560,7 +560,7 @@ static int tree_iterator__update_entry(tree_iterator *ti) return 0; } -static int tree_iterator__current( +static int tree_iterator__current_internal( const git_index_entry **entry, git_iterator *self) { int error; @@ -583,6 +583,39 @@ static int tree_iterator__current( return 0; } +int tree_iterator__advance( + const git_index_entry **out, git_iterator *self); + +static int tree_iterator__current( + const git_index_entry **out, git_iterator *self) +{ + git_index_entry *entry = NULL; + iterator_pathlist__match_t m; + int error; + + do { + if ((error = tree_iterator__current_internal(&entry, self)) < 0) + return error; + + if (self->pathlist.length) { + m = iterator_pathlist__match( + self, entry->path, strlen(entry->path)); + + if (m != ITERATOR_PATHLIST_MATCH) { + if ((error = tree_iterator__advance(&entry, self)) < 0) + return error; + + entry = NULL; + } + } + } while (!entry); + + if (out) + *out = entry; + + return error; +} + static int tree_iterator__advance_into( const git_index_entry **entry, git_iterator *self) { |