diff options
author | Russell Belfer <rb@github.com> | 2013-05-31 23:18:43 +0400 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2013-05-31 23:18:43 +0400 |
commit | cee695ae6b9a9f586d32d0b9460a358bfdc4fe1b (patch) | |
tree | 33fa5cceec1bbb24ab919ccb21732cd1487d4fec /src/notes.c | |
parent | 1ed356dcfef449313bac3ce795f26d19423c744c (diff) |
Make iterators use GIT_ITEROVER & smart advance
1. internal iterators now return GIT_ITEROVER when you go past the
last item in the iteration.
2. git_iterator_advance will "advance" to the first item in the
iteration if it is called immediately after creating the
iterator, which allows a simpler idiom for basic iteration.
3. if git_iterator_advance encounters an error reading data (e.g.
a missing tree or an unreadable file), it returns the error
but also attempts to advance past the invalid data to prevent
an infinite loop.
Updated all tests and internal usage of iterators to account for
these new behaviors.
Diffstat (limited to 'src/notes.c')
-rw-r--r-- | src/notes.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/src/notes.c b/src/notes.c index 3e3db58db..beace1b50 100644 --- a/src/notes.c +++ b/src/notes.c @@ -647,18 +647,12 @@ int git_note_next( const git_index_entry *item; if ((error = git_iterator_current(&item, it)) < 0) - goto exit; + return error; - if (item != NULL) { - git_oid_cpy(note_id, &item->oid); - error = process_entry_path(item->path, annotated_id); + git_oid_cpy(note_id, &item->oid); - if (error >= 0) - error = git_iterator_advance(NULL, it); - } else { - error = GIT_ITEROVER; - } + if (!(error = process_entry_path(item->path, annotated_id))) + git_iterator_advance(NULL, it); -exit: return error; } |