summaryrefslogtreecommitdiff
path: root/src/iterator.h
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2012-12-06 13:26:58 -0800
committerRussell Belfer <rb@github.com>2012-12-10 15:38:28 -0800
commit9950d27ab62cc31a3ebf1944fd33dd65432be790 (patch)
treeca7c8efe8b4a5d6e2adc0ae66e26d22a03c76155 /src/iterator.h
parent4cbe9a1be18338b7e223b42e6019c58181204123 (diff)
downloadlibgit2-9950d27ab62cc31a3ebf1944fd33dd65432be790.tar.gz
Clean up iterator APIs
This removes the need to explicitly pass the repo into iterators where the repo is implied by the other parameters. This moves the repo to be owned by the parent struct. Also, this has some iterator related updates to the internal diff API to lay the groundwork for checkout improvements.
Diffstat (limited to 'src/iterator.h')
-rw-r--r--src/iterator.h21
1 files changed, 14 insertions, 7 deletions
diff --git a/src/iterator.h b/src/iterator.h
index 77ead76cc..07cce5a5a 100644
--- a/src/iterator.h
+++ b/src/iterator.h
@@ -28,32 +28,33 @@ typedef enum {
struct git_iterator {
git_iterator_type_t type;
+ git_repository *repo;
char *start;
char *end;
+ bool ignore_case;
+
int (*current)(git_iterator *, const git_index_entry **);
int (*at_end)(git_iterator *);
int (*advance)(git_iterator *, const git_index_entry **);
int (*seek)(git_iterator *, const char *prefix);
int (*reset)(git_iterator *);
void (*free)(git_iterator *);
- unsigned int ignore_case:1;
};
extern int git_iterator_for_nothing(git_iterator **iter);
extern int git_iterator_for_tree_range(
- git_iterator **iter, git_repository *repo, git_tree *tree,
+ git_iterator **iter, git_tree *tree,
const char *start, const char *end);
GIT_INLINE(int) git_iterator_for_tree(
- git_iterator **iter, git_repository *repo, git_tree *tree)
+ git_iterator **iter, git_tree *tree)
{
- return git_iterator_for_tree_range(iter, repo, tree, NULL, NULL);
+ return git_iterator_for_tree_range(iter, tree, NULL, NULL);
}
extern int git_iterator_for_index_range(
- git_iterator **iter, git_index *index,
- const char *start, const char *end);
+ git_iterator **iter, git_index *index, const char *start, const char *end);
GIT_INLINE(int) git_iterator_for_index(
git_iterator **iter, git_index *index)
@@ -90,7 +91,8 @@ GIT_INLINE(int) git_iterator_spoolandsort(
git_iterator **iter, git_iterator *towrap,
git_vector_cmp comparer, bool ignore_case)
{
- return git_iterator_spoolandsort_range(iter, towrap, comparer, ignore_case, NULL, NULL);
+ return git_iterator_spoolandsort_range(
+ iter, towrap, comparer, ignore_case, NULL, NULL);
}
/* Entry is not guaranteed to be fully populated. For a tree iterator,
@@ -149,6 +151,11 @@ GIT_INLINE(git_iterator_type_t) git_iterator_type(git_iterator *iter)
return iter->type;
}
+GIT_INLINE(git_repository *) git_iterator_owner(git_iterator *iter)
+{
+ return iter->repo;
+}
+
extern int git_iterator_current_tree_entry(
git_iterator *iter, const git_tree_entry **tree_entry);