Commit 2bd5998c by Russell Belfer

Remove git_note_data structure

parent 336d1275
...@@ -19,20 +19,15 @@ ...@@ -19,20 +19,15 @@
GIT_BEGIN_DECL 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. * 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 * Read the note for an object
...@@ -150,8 +145,7 @@ GIT_EXTERN(int) git_note_foreach( ...@@ -150,8 +145,7 @@ GIT_EXTERN(int) git_note_foreach(
git_repository *repo, git_repository *repo,
const char *notes_ref, const char *notes_ref,
git_note_foreach_cb note_cb, git_note_foreach_cb note_cb,
void *payload void *payload);
);
/** @} */ /** @} */
GIT_END_DECL GIT_END_DECL
......
...@@ -534,7 +534,7 @@ static int process_entry_path( ...@@ -534,7 +534,7 @@ static int process_entry_path(
int error = -1; int error = -1;
size_t i = 0, j = 0, len; size_t i = 0, j = 0, len;
git_buf buf = GIT_BUF_INIT; 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) if ((error = git_buf_puts(&buf, entry_path)) < 0)
goto cleanup; goto cleanup;
...@@ -567,13 +567,10 @@ static int process_entry_path( ...@@ -567,13 +567,10 @@ static int process_entry_path(
goto cleanup; goto cleanup;
} }
if ((error = git_oid_fromstr( if ((error = git_oid_fromstr(&annotated_object_id, buf.ptr)) < 0)
&note_data.annotated_object_oid, buf.ptr)) < 0)
goto cleanup; goto cleanup;
git_oid_cpy(&note_data.blob_oid, note_oid); if (note_cb(note_oid, &annotated_object_id, payload))
if (note_cb(&note_data, payload))
error = GIT_EUSER; error = GIT_EUSER;
cleanup: cleanup:
......
...@@ -50,7 +50,8 @@ static struct { ...@@ -50,7 +50,8 @@ static struct {
#define EXPECTATIONS_COUNT (sizeof(list_expectations)/sizeof(list_expectations[0])) - 1 #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; git_oid expected_note_oid, expected_target_oid;
...@@ -59,10 +60,10 @@ static int note_list_cb(git_note_data *note_data, void *payload) ...@@ -59,10 +60,10 @@ static int note_list_cb(git_note_data *note_data, void *payload)
cl_assert(*count < EXPECTATIONS_COUNT); cl_assert(*count < EXPECTATIONS_COUNT);
cl_git_pass(git_oid_fromstr(&expected_note_oid, list_expectations[*count].note_sha)); 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_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)++; (*count)++;
...@@ -103,11 +104,13 @@ void test_notes_notes__can_retrieve_a_list_of_notes_for_a_given_namespace(void) ...@@ -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); 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; unsigned int *count = (unsigned int *)payload;
GIT_UNUSED(note_data); GIT_UNUSED(blob_id);
GIT_UNUSED(annotated_obj_id);
(*count)++; (*count)++;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment