summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2012-11-27 14:47:39 -0800
committerRussell Belfer <rb@github.com>2012-11-27 14:47:39 -0800
commit2bd5998c9cab0afdea2aba00ce35a70656ba9fda (patch)
tree64564d82a5fe3f6cbdc331efe6c5eaaf0f6e6e4c
parent336d1275ca53e7acc0b1b28986513a3061260a22 (diff)
downloadlibgit2-2bd5998c9cab0afdea2aba00ce35a70656ba9fda.tar.gz
Remove git_note_data structure
-rw-r--r--include/git2/notes.h22
-rw-r--r--src/notes.c9
-rw-r--r--tests-clar/notes/notes.c13
3 files changed, 19 insertions, 25 deletions
diff --git a/include/git2/notes.h b/include/git2/notes.h
index 765ee5ddd..ae66975cd 100644
--- a/include/git2/notes.h
+++ b/include/git2/notes.h
@@ -19,20 +19,15 @@
GIT_BEGIN_DECL
/**
- * Basic components of a note
- *
- * - Oid of the blob containing the message
- * - Oid of the git object being annotated
- */
-typedef struct {
- git_oid blob_oid;
- git_oid annotated_object_oid;
-} git_note_data;
-
-/**
* Callback for git_note_foreach.
+ *
+ * Receives:
+ * - blob_id: Oid of the blob containing the message
+ * - annotated_object_id: Oid of the git object being annotated
+ * - payload: Payload data passed to `git_note_foreach`
*/
-typedef int (*git_note_foreach_cb)(git_note_data *note_data, void *payload);
+typedef int (*git_note_foreach_cb)(
+ const git_oid *blob_id, const git_oid *annotated_object_id, void *payload);
/**
* Read the note for an object
@@ -150,8 +145,7 @@ GIT_EXTERN(int) git_note_foreach(
git_repository *repo,
const char *notes_ref,
git_note_foreach_cb note_cb,
- void *payload
-);
+ void *payload);
/** @} */
GIT_END_DECL
diff --git a/src/notes.c b/src/notes.c
index debf64133..dd36cc2fe 100644
--- a/src/notes.c
+++ b/src/notes.c
@@ -534,7 +534,7 @@ static int process_entry_path(
int error = -1;
size_t i = 0, j = 0, len;
git_buf buf = GIT_BUF_INIT;
- git_note_data note_data;
+ git_oid annotated_object_id;
if ((error = git_buf_puts(&buf, entry_path)) < 0)
goto cleanup;
@@ -567,13 +567,10 @@ static int process_entry_path(
goto cleanup;
}
- if ((error = git_oid_fromstr(
- &note_data.annotated_object_oid, buf.ptr)) < 0)
+ if ((error = git_oid_fromstr(&annotated_object_id, buf.ptr)) < 0)
goto cleanup;
- git_oid_cpy(&note_data.blob_oid, note_oid);
-
- if (note_cb(&note_data, payload))
+ if (note_cb(note_oid, &annotated_object_id, payload))
error = GIT_EUSER;
cleanup:
diff --git a/tests-clar/notes/notes.c b/tests-clar/notes/notes.c
index 706bc03ce..3f5194c51 100644
--- a/tests-clar/notes/notes.c
+++ b/tests-clar/notes/notes.c
@@ -50,7 +50,8 @@ static struct {
#define EXPECTATIONS_COUNT (sizeof(list_expectations)/sizeof(list_expectations[0])) - 1
-static int note_list_cb(git_note_data *note_data, void *payload)
+static int note_list_cb(
+ const git_oid *blob_id, const git_oid *annotated_obj_id, void *payload)
{
git_oid expected_note_oid, expected_target_oid;
@@ -59,10 +60,10 @@ static int note_list_cb(git_note_data *note_data, void *payload)
cl_assert(*count < EXPECTATIONS_COUNT);
cl_git_pass(git_oid_fromstr(&expected_note_oid, list_expectations[*count].note_sha));
- cl_assert(git_oid_cmp(&expected_note_oid, &note_data->blob_oid) == 0);
+ cl_assert(git_oid_cmp(&expected_note_oid, blob_id) == 0);
cl_git_pass(git_oid_fromstr(&expected_target_oid, list_expectations[*count].annotated_object_sha));
- cl_assert(git_oid_cmp(&expected_target_oid, &note_data->annotated_object_oid) == 0);
+ cl_assert(git_oid_cmp(&expected_target_oid, annotated_obj_id) == 0);
(*count)++;
@@ -103,11 +104,13 @@ void test_notes_notes__can_retrieve_a_list_of_notes_for_a_given_namespace(void)
cl_assert_equal_i(4, retrieved_notes);
}
-static int note_cancel_cb(git_note_data *note_data, void *payload)
+static int note_cancel_cb(
+ const git_oid *blob_id, const git_oid *annotated_obj_id, void *payload)
{
unsigned int *count = (unsigned int *)payload;
- GIT_UNUSED(note_data);
+ GIT_UNUSED(blob_id);
+ GIT_UNUSED(annotated_obj_id);
(*count)++;