summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorschu <schu-github@schulog.org>2012-02-15 00:33:38 +0100
committerschu <schu-github@schulog.org>2012-02-15 20:32:14 +0100
commitbf477ed4a86d4183f7e38e4667a1f623270bf5d2 (patch)
treea3a4752971f2f8e031e78c78e48f5d142e7210ea /include
parent905919e63b7b4357ca75ef5e8bfeca7485428dc9 (diff)
downloadlibgit2-bf477ed4a86d4183f7e38e4667a1f623270bf5d2.tar.gz
Add git notes API
This commit adds basic git notes support to libgit2, namely: * git_note_read * git_note_message * git_note_oid * git_note_create * git_note_remove In the long run, we probably want to provide some convenience callback mechanism for merging and moving (filter-branch) notes. Signed-off-by: schu <schu-github@schulog.org>
Diffstat (limited to 'include')
-rw-r--r--include/git2.h2
-rw-r--r--include/git2/notes.h97
-rw-r--r--include/git2/types.h3
3 files changed, 102 insertions, 0 deletions
diff --git a/include/git2.h b/include/git2.h
index d68a04efd..e5b9bf55e 100644
--- a/include/git2.h
+++ b/include/git2.h
@@ -41,4 +41,6 @@
#include "git2/status.h"
#include "git2/indexer.h"
+#include "git2/notes.h"
+
#endif
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 */