diff options
| author | Vicent Martà <vicent@github.com> | 2012-02-15 11:38:40 -0800 |
|---|---|---|
| committer | Vicent Martà <vicent@github.com> | 2012-02-15 11:38:40 -0800 |
| commit | 6117895fef92ddd08c437ce5a7cdc4bf56754cc3 (patch) | |
| tree | a38b27a3bab5c44daaab2c6b07438dc3e5cf67d9 /include/git2 | |
| parent | 0c3bae6268c404fc3717cc90ba1bc5db91c8cbe6 (diff) | |
| parent | bf477ed4a86d4183f7e38e4667a1f623270bf5d2 (diff) | |
| download | libgit2-6117895fef92ddd08c437ce5a7cdc4bf56754cc3.tar.gz | |
Merge pull request #558 from schu/notes-api
Notes API
Diffstat (limited to 'include/git2')
| -rw-r--r-- | include/git2/commit.h | 3 | ||||
| -rw-r--r-- | include/git2/notes.h | 97 | ||||
| -rw-r--r-- | include/git2/types.h | 3 |
3 files changed, 102 insertions, 1 deletions
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 */ |
