summaryrefslogtreecommitdiff
path: root/include/git2/notes.h
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2012-08-03 17:08:01 -0700
committerRussell Belfer <rb@github.com>2012-08-03 17:08:01 -0700
commit5dca201072724e4230141796d7c9f8836a277de8 (patch)
tree7eb6b8f3e08c8abc608ee43c0ddc32d4d043a2c6 /include/git2/notes.h
parent2031760c626711cc69b4d63ac9798ff333583ca0 (diff)
downloadlibgit2-5dca201072724e4230141796d7c9f8836a277de8.tar.gz
Update iterators for consistency across library
This updates all the `foreach()` type functions across the library that take callbacks from the user to have a consistent behavior. The rules are: * A callback terminates the loop by returning any non-zero value * Once the callback returns non-zero, it will not be called again (i.e. the loop stops all iteration regardless of state) * If the callback returns non-zero, the parent fn returns GIT_EUSER * Although the parent returns GIT_EUSER, no error will be set in the library and `giterr_last()` will return NULL if called. This commit makes those changes across the library and adds tests for most of the iteration APIs to make sure that they follow the above rules.
Diffstat (limited to 'include/git2/notes.h')
-rw-r--r--include/git2/notes.h16
1 files changed, 9 insertions, 7 deletions
diff --git a/include/git2/notes.h b/include/git2/notes.h
index 19073abd1..b4839bec3 100644
--- a/include/git2/notes.h
+++ b/include/git2/notes.h
@@ -119,19 +119,21 @@ typedef struct {
*
* @param repo Repository where to find the notes.
*
- * @param notes_ref OID reference to read from (optional); defaults to "refs/notes/commits".
+ * @param notes_ref OID reference to read from (optional); defaults to
+ * "refs/notes/commits".
*
- * @param note_cb Callback to invoke per found annotation.
+ * @param note_cb Callback to invoke per found annotation. Return non-zero
+ * to stop looping.
*
* @param payload Extra parameter to callback function.
*
- * @return 0 or an error code.
+ * @return 0 on success, GIT_EUSER on non-zero callback, or error code
*/
GIT_EXTERN(int) git_note_foreach(
- git_repository *repo,
- const char *notes_ref,
- int (*note_cb)(git_note_data *note_data, void *payload),
- void *payload
+ git_repository *repo,
+ const char *notes_ref,
+ int (*note_cb)(git_note_data *note_data, void *payload),
+ void *payload
);
/** @} */