API updates for notes.h/c.
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 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227
diff --git a/include/git2/notes.h b/include/git2/notes.h
index af480a4..765ee5d 100644
--- a/include/git2/notes.h
+++ b/include/git2/notes.h
@@ -19,20 +19,39 @@
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.
+ */
+typedef int (*git_note_foreach_cb)(git_note_data *note_data, void *payload);
+
+/**
* Read the note for an object
*
* The note must be freed manually by the user.
*
- * @param note pointer to the read note; NULL in case of error
+ * @param out pointer to the read note; NULL in case of error
* @param repo repository where to look up the note
- * @param notes_ref canonical name of the reference to use (optional);
- * defaults to "refs/notes/commits"
+ * @param notes_ref canonical name of the reference to use (optional); defaults to
+ * "refs/notes/commits"
* @param oid OID of the git object to read the note from
*
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_note_read(git_note **note, git_repository *repo,
- const char *notes_ref, const git_oid *oid);
+GIT_EXTERN(int) git_note_read(
+ git_note **out,
+ git_repository *repo,
+ const char *notes_ref,
+ const git_oid *oid);
/**
* Get the note message
@@ -40,7 +59,7 @@ GIT_EXTERN(int) git_note_read(git_note **note, git_repository *repo,
* @param note
* @return the note message
*/
-GIT_EXTERN(const char *) git_note_message(git_note *note);
+GIT_EXTERN(const char *) git_note_message(const git_note *note);
/**
@@ -49,7 +68,7 @@ GIT_EXTERN(const char *) git_note_message(git_note *note);
* @param note
* @return the note object OID
*/
-GIT_EXTERN(const git_oid *) git_note_oid(git_note *note);
+GIT_EXTERN(const git_oid *) git_note_oid(const git_note *note);
/**
* Add a note for an object
@@ -65,10 +84,14 @@ GIT_EXTERN(const git_oid *) git_note_oid(git_note *note);
*
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_note_create(git_oid *out, git_repository *repo,
- git_signature *author, git_signature *committer,
- const char *notes_ref, const git_oid *oid,
- const char *note);
+GIT_EXTERN(int) git_note_create(
+ git_oid *out,
+ git_repository *repo,
+ const git_signature *author,
+ const git_signature *committer,
+ const char *notes_ref,
+ const git_oid *oid,
+ const char *note);
/**
@@ -83,9 +106,12 @@ GIT_EXTERN(int) git_note_create(git_oid *out, git_repository *repo,
*
* @return 0 or an error code
*/
-GIT_EXTERN(int) git_note_remove(git_repository *repo, const char *notes_ref,
- git_signature *author, git_signature *committer,
- const git_oid *oid);
+GIT_EXTERN(int) git_note_remove(
+ git_repository *repo,
+ const char *notes_ref,
+ const git_signature *author,
+ const git_signature *committer,
+ const git_oid *oid);
/**
* Free a git_note object
@@ -105,17 +131,6 @@ GIT_EXTERN(void) git_note_free(git_note *note);
GIT_EXTERN(int) git_note_default_ref(const char **out, git_repository *repo);
/**
- * 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;
-
-/**
* Loop over all the notes within a specified namespace
* and issue a callback for each one.
*
@@ -134,7 +149,7 @@ typedef struct {
GIT_EXTERN(int) git_note_foreach(
git_repository *repo,
const char *notes_ref,
- int (*note_cb)(git_note_data *note_data, void *payload),
+ git_note_foreach_cb note_cb,
void *payload
);
diff --git a/src/notes.c b/src/notes.c
index 95ff017..debf641 100644
--- a/src/notes.c
+++ b/src/notes.c
@@ -263,8 +263,8 @@ static int insert_note_in_tree_enotfound_cb(git_tree **out,
static int note_write(git_oid *out,
git_repository *repo,
- git_signature *author,
- git_signature *committer,
+ const git_signature *author,
+ const git_signature *committer,
const char *notes_ref,
const char *note,
git_tree *commit_tree,
@@ -343,9 +343,9 @@ cleanup:
}
static int note_remove(git_repository *repo,
- git_signature *author, git_signature *committer,
- const char *notes_ref, git_tree *tree,
- const char *target, git_commit **parents)
+ const git_signature *author, const git_signature *committer,
+ const char *notes_ref, git_tree *tree,
+ const char *target, git_commit **parents)
{
int error;
git_tree *tree_after_removal = NULL;
@@ -442,9 +442,12 @@ cleanup:
}
int git_note_create(
- git_oid *out, git_repository *repo,
- git_signature *author, git_signature *committer,
- const char *notes_ref, const git_oid *oid,
+ git_oid *out,
+ git_repository *repo,
+ const git_signature *author,
+ const git_signature *committer,
+ const char *notes_ref,
+ const git_oid *oid,
const char *note)
{
int error;
@@ -461,7 +464,7 @@ int git_note_create(
goto cleanup;
error = note_write(out, repo, author, committer, notes_ref,
- note, tree, target, &commit);
+ note, tree, target, &commit);
cleanup:
git__free(target);
@@ -471,8 +474,8 @@ cleanup:
}
int git_note_remove(git_repository *repo, const char *notes_ref,
- git_signature *author, git_signature *committer,
- const git_oid *oid)
+ const git_signature *author, const git_signature *committer,
+ const git_oid *oid)
{
int error;
char *target = NULL;
@@ -501,13 +504,13 @@ int git_note_default_ref(const char **out, git_repository *repo)
return note_get_default_ref(out, repo);
}
-const char * git_note_message(git_note *note)
+const char * git_note_message(const git_note *note)
{
assert(note);
return note->message;
}
-const git_oid * git_note_oid(git_note *note)
+const git_oid * git_note_oid(const git_note *note)
{
assert(note);
return ¬e->oid;
@@ -525,7 +528,7 @@ void git_note_free(git_note *note)
static int process_entry_path(
const char* entry_path,
const git_oid *note_oid,
- int (*note_cb)(git_note_data *note_data, void *payload),
+ git_note_foreach_cb note_cb,
void *payload)
{
int error = -1;
@@ -581,7 +584,7 @@ cleanup:
int git_note_foreach(
git_repository *repo,
const char *notes_ref,
- int (*note_cb)(git_note_data *note_data, void *payload),
+ git_note_foreach_cb note_cb,
void *payload)
{
int error;