mirror of
https://git.proxmox.com/git/libgit2
synced 2025-05-19 20:37:41 +00:00
API updates for notes.h/c.
This commit is contained in:
parent
05a3ab61c2
commit
de5596bfd6
@ -18,21 +18,40 @@
|
||||
*/
|
||||
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,9 +84,13 @@ 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,
|
||||
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,8 +106,11 @@ 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,
|
||||
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);
|
||||
|
||||
/**
|
||||
@ -104,17 +130,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
|
||||
);
|
||||
|
||||
|
25
src/notes.c
25
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,7 +343,7 @@ cleanup:
|
||||
}
|
||||
|
||||
static int note_remove(git_repository *repo,
|
||||
git_signature *author, git_signature *committer,
|
||||
const git_signature *author, const git_signature *committer,
|
||||
const char *notes_ref, git_tree *tree,
|
||||
const char *target, git_commit **parents)
|
||||
{
|
||||
@ -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;
|
||||
@ -471,7 +474,7 @@ cleanup:
|
||||
}
|
||||
|
||||
int git_note_remove(git_repository *repo, const char *notes_ref,
|
||||
git_signature *author, git_signature *committer,
|
||||
const git_signature *author, const git_signature *committer,
|
||||
const git_oid *oid)
|
||||
{
|
||||
int error;
|
||||
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user