diff options
Diffstat (limited to 'include')
| -rw-r--r-- | include/git2.h | 2 | ||||
| -rw-r--r-- | include/git2/commit.h | 3 | ||||
| -rw-r--r-- | include/git2/notes.h | 97 | ||||
| -rw-r--r-- | include/git2/types.h | 3 |
4 files changed, 104 insertions, 1 deletions
diff --git a/include/git2.h b/include/git2.h index 3d7c4f626..5a55bb284 100644 --- a/include/git2.h +++ b/include/git2.h @@ -40,4 +40,6 @@ #include "git2/status.h" #include "git2/indexer.h" +#include "git2/notes.h" + #endif diff --git a/include/git2/commit.h b/include/git2/commit.h index 6d8cf53af..c274b6b95 100644 --- a/include/git2/commit.h +++ b/include/git2/commit.h @@ -191,7 +191,8 @@ GIT_EXTERN(const git_oid *) git_commit_parent_oid(git_commit *commit, unsigned i * will be updated to point to this commit. If the reference * is not direct, it will be resolved to a direct reference. * Use "HEAD" to update the HEAD of the current branch and - * make it point to this commit + * make it point to this commit. If the reference doesn't + * exist yet, it will be created. * * @param author Signature representing the author and the authory * time of this commit diff --git a/include/git2/notes.h b/include/git2/notes.h new file mode 100644 index 000000000..1b5944f9d --- /dev/null +++ b/include/git2/notes.h @@ -0,0 +1,97 @@ +/* + * Copyright (C) 2009-2012 the libgit2 contributors + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ +#ifndef INCLUDE_git_note_h__ +#define INCLUDE_git_note_h__ + +#include "oid.h" + +/** + * @file git2/notes.h + * @brief Git notes management routines + * @defgroup git_note Git notes management routines + * @ingroup Git + * @{ + */ +GIT_BEGIN_DECL + +/** + * Read the note for an object + * + * The note must be freed manually by the user. + * + * @param note the note; NULL in case of error + * @param repo the Git repository + * @param notes_ref OID reference to use (optional); defaults to "refs/notes/commits" + * @param oid OID of the object + * + * @return GIT_SUCCESS or an error code + */ +GIT_EXTERN(int) git_note_read(git_note **note, git_repository *repo, + const char *notes_ref, const git_oid *oid); + +/** + * Get the note message + * + * @param note + * @return the note message + */ +GIT_EXTERN(const char *) git_note_message(git_note *note); + + +/** + * Get the note object OID + * + * @param note + * @return the note object OID + */ +GIT_EXTERN(const git_oid *) git_note_oid(git_note *note); + + +/** + * Add a note for an object + * + * @param oid pointer to store the OID (optional); NULL in case of error + * @param repo the Git repository + * @param author signature of the notes commit author + * @param committer signature of the notes commit committer + * @param notes_ref OID reference to update (optional); defaults to "refs/notes/commits" + * @param oid The OID of the object + * @param oid The note to add for object oid + * + * @return GIT_SUCCESS 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); + + +/** + * Remove the note for an object + * + * @param repo the Git repository + * @param notes_ref OID reference to use (optional); defaults to "refs/notes/commits" + * @param author signature of the notes commit author + * @param committer signature of the notes commit committer + * @param oid the oid which note's to be removed + * + * @return GIT_SUCCESS 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); + +/** + * Free a git_note object + * + * @param note git_note object + */ +GIT_EXTERN(void) git_note_free(git_note *note); + +/** @} */ +GIT_END_DECL +#endif diff --git a/include/git2/types.h b/include/git2/types.h index 669e4cc4e..ffada630a 100644 --- a/include/git2/types.h +++ b/include/git2/types.h @@ -131,6 +131,9 @@ typedef struct git_reflog_entry git_reflog_entry; /** Representation of a reference log */ typedef struct git_reflog git_reflog; +/** Representation of a git note */ +typedef struct git_note git_note; + /** Time in a signature */ typedef struct git_time { git_time_t time; /** time in seconds from epoch */ |
