void test_notes_notes__can_iterate_custom_namespace(void) { git_note_iterator *iter; git_note *note; git_oid note_id, annotated_id; git_oid note_created[2]; const char* note_message[] = { "I decorate a65f\n", "I decorate c478\n" }; int i, err; create_note(¬e_created[0], "refs/notes/beer", "a65fedf39aefe402d3bb6e24df4d4f5fe4547750", note_message[0]); create_note(¬e_created[1], "refs/notes/beer", "c47800c7266a2be04c571c04d5a6614691ea99bd", note_message[1]); cl_git_pass(git_note_iterator_new(&iter, _repo, "refs/notes/beer")); for (i = 0; (err = git_note_next(¬e_id, &annotated_id, iter)) >= 0; ++i) { cl_git_pass(git_note_read(¬e, _repo, "refs/notes/beer", &annotated_id)); cl_assert_equal_s(git_note_message(note), note_message[i]); git_note_free(note); } cl_assert_equal_i(GIT_ITEROVER, err); cl_assert_equal_i(2, i); git_note_iterator_free(iter); }
int git_note_foreach( git_repository *repo, const char *notes_ref, git_note_foreach_cb note_cb, void *payload) { int error; git_note_iterator *iter = NULL; git_oid note_id, annotated_id; if ((error = git_note_iterator_new(&iter, repo, notes_ref)) < 0) return error; while (!(error = git_note_next(¬e_id, &annotated_id, iter))) { if (note_cb(¬e_id, &annotated_id, payload)) { error = GIT_EUSER; break; } } if (error == GIT_ITEROVER) error = 0; git_note_iterator_free(iter); return error; }
PyObject * Repository_notes(Repository *self, PyObject *args) { NoteIter *iter = NULL; char *ref = "refs/notes/commits"; int err = GIT_ERROR; if (!PyArg_ParseTuple(args, "|s", &ref)) return NULL; iter = PyObject_New(NoteIter, &NoteIterType); if (iter != NULL) { iter->repo = self; iter->ref = ref; err = git_note_iterator_new(&iter->iter, self->repo, iter->ref); if (err == GIT_OK) { Py_INCREF(self); return (PyObject*)iter; } } return Error_set(err); }
void test_notes_notes__empty_iterate(void) { git_note_iterator *iter; cl_git_fail(git_note_iterator_new(&iter, _repo, "refs/notes/commits")); }