diff options
author | Carlos Martín Nieto <cmn@dwim.me> | 2013-03-02 22:31:03 +0400 |
---|---|---|
committer | Carlos Martín Nieto <cmn@dwim.me> | 2013-05-11 13:20:37 +0400 |
commit | 4def7035cac133607256fd91352ce54ac4548a7c (patch) | |
tree | 6956733c0ef644f9f2a6bea1e603e3fcb72fd954 /src/refs.c | |
parent | b641c00eebb3c60e8719c0dfc55dde91ca30a5d2 (diff) |
refs: introduce an iterator
This allows us to get a list of reference names in a loop instead of callbacks.
Diffstat (limited to 'src/refs.c')
-rw-r--r-- | src/refs.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/src/refs.c b/src/refs.c index b85a2e828..547bd570c 100644 --- a/src/refs.c +++ b/src/refs.c @@ -568,6 +568,26 @@ int git_reference_foreach( return git_refdb_foreach(refdb, list_flags, callback, payload); } +int git_reference_iterator_new(git_reference_iterator **out, git_repository *repo) +{ + git_refdb *refdb; + + if (git_repository_refdb__weakptr(&refdb, repo) < 0) + return -1; + + return git_refdb_iterator(out, refdb); +} + +int git_reference_next(const char **out, git_reference_iterator *iter) +{ + return git_refdb_next(out, iter); +} + +void git_reference_iterator_free(git_reference_iterator *iter) +{ + git_refdb_iterator_free(iter); +} + static int cb__reflist_add(const char *ref, void *data) { return git_vector_insert((git_vector *)data, git__strdup(ref)); |