Remove git_note_data structure
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114
diff --git a/include/git2/notes.h b/include/git2/notes.h
index 765ee5d..ae66975 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 debf641..dd36cc2 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(
- ¬e_data.annotated_object_oid, buf.ptr)) < 0)
+ if ((error = git_oid_fromstr(&annotated_object_id, buf.ptr)) < 0)
goto cleanup;
- git_oid_cpy(¬e_data.blob_oid, note_oid);
-
- if (note_cb(¬e_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 706bc03..3f5194c 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, ¬e_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, ¬e_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)++;