Blame include/git2/notes.h

Packit ae9e2a
/*
Packit ae9e2a
 * Copyright (C) the libgit2 contributors. All rights reserved.
Packit ae9e2a
 *
Packit ae9e2a
 * This file is part of libgit2, distributed under the GNU GPL v2 with
Packit ae9e2a
 * a Linking Exception. For full terms see the included COPYING file.
Packit ae9e2a
 */
Packit ae9e2a
#ifndef INCLUDE_git_note_h__
Packit ae9e2a
#define INCLUDE_git_note_h__
Packit ae9e2a
Packit ae9e2a
#include "oid.h"
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * @file git2/notes.h
Packit ae9e2a
 * @brief Git notes management routines
Packit ae9e2a
 * @defgroup git_note Git notes management routines
Packit ae9e2a
 * @ingroup Git
Packit ae9e2a
 * @{
Packit ae9e2a
 */
Packit ae9e2a
GIT_BEGIN_DECL
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Callback for git_note_foreach.
Packit ae9e2a
 *
Packit ae9e2a
 * Receives:
Packit ae9e2a
 * - blob_id: Oid of the blob containing the message
Packit ae9e2a
 * - annotated_object_id: Oid of the git object being annotated
Packit ae9e2a
 * - payload: Payload data passed to `git_note_foreach`
Packit ae9e2a
 */
Packit ae9e2a
typedef int (*git_note_foreach_cb)(
Packit ae9e2a
	const git_oid *blob_id, const git_oid *annotated_object_id, void *payload);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * note iterator
Packit ae9e2a
 */
Packit ae9e2a
typedef struct git_iterator git_note_iterator;
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Creates a new iterator for notes
Packit ae9e2a
 *
Packit ae9e2a
 * The iterator must be freed manually by the user.
Packit ae9e2a
 *
Packit ae9e2a
 * @param out pointer to the iterator
Packit ae9e2a
 * @param repo repository where to look up the note
Packit ae9e2a
 * @param notes_ref canonical name of the reference to use (optional); defaults to
Packit ae9e2a
 *                  "refs/notes/commits"
Packit ae9e2a
 *
Packit ae9e2a
 * @return 0 or an error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_note_iterator_new(
Packit ae9e2a
	git_note_iterator **out,
Packit ae9e2a
	git_repository *repo,
Packit ae9e2a
	const char *notes_ref);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Frees an git_note_iterator
Packit ae9e2a
 *
Packit ae9e2a
 * @param it pointer to the iterator
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(void) git_note_iterator_free(git_note_iterator *it);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Return the current item (note_id and annotated_id) and advance the iterator
Packit ae9e2a
 * internally to the next value
Packit ae9e2a
 *
Packit ae9e2a
 * @param note_id id of blob containing the message
Packit ae9e2a
 * @param annotated_id id of the git object being annotated
Packit ae9e2a
 * @param it pointer to the iterator
Packit ae9e2a
 *
Packit ae9e2a
 * @return 0 (no error), GIT_ITEROVER (iteration is done) or an error code
Packit ae9e2a
 *         (negative value)
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_note_next(
Packit ae9e2a
	git_oid* note_id,
Packit ae9e2a
	git_oid* annotated_id,
Packit ae9e2a
	git_note_iterator *it);
Packit ae9e2a
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Read the note for an object
Packit ae9e2a
 *
Packit ae9e2a
 * The note must be freed manually by the user.
Packit ae9e2a
 *
Packit ae9e2a
 * @param out pointer to the read note; NULL in case of error
Packit ae9e2a
 * @param repo repository where to look up the note
Packit ae9e2a
 * @param notes_ref canonical name of the reference to use (optional); defaults to
Packit ae9e2a
 *                  "refs/notes/commits"
Packit ae9e2a
 * @param oid OID of the git object to read the note from
Packit ae9e2a
 *
Packit ae9e2a
 * @return 0 or an error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_note_read(
Packit ae9e2a
	git_note **out,
Packit ae9e2a
	git_repository *repo,
Packit ae9e2a
	const char *notes_ref,
Packit ae9e2a
	const git_oid *oid);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Get the note author
Packit ae9e2a
 *
Packit ae9e2a
 * @param note the note
Packit ae9e2a
 * @return the author
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(const git_signature *) git_note_author(const git_note *note);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Get the note committer
Packit ae9e2a
 *
Packit ae9e2a
 * @param note the note
Packit ae9e2a
 * @return the committer
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(const git_signature *) git_note_committer(const git_note *note);
Packit ae9e2a
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Get the note message
Packit ae9e2a
 *
Packit ae9e2a
 * @param note the note
Packit ae9e2a
 * @return the note message
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(const char *) git_note_message(const git_note *note);
Packit ae9e2a
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Get the note object's id
Packit ae9e2a
 *
Packit ae9e2a
 * @param note the note
Packit ae9e2a
 * @return the note object's id
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(const git_oid *) git_note_id(const git_note *note);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Add a note for an object
Packit ae9e2a
 *
Packit ae9e2a
 * @param out pointer to store the OID (optional); NULL in case of error
Packit ae9e2a
 * @param repo repository where to store the note
Packit ae9e2a
 * @param notes_ref canonical name of the reference to use (optional);
Packit ae9e2a
 *					defaults to "refs/notes/commits"
Packit ae9e2a
 * @param author signature of the notes commit author
Packit ae9e2a
 * @param committer signature of the notes commit committer
Packit ae9e2a
 * @param oid OID of the git object to decorate
Packit ae9e2a
 * @param note Content of the note to add for object oid
Packit ae9e2a
 * @param force Overwrite existing note
Packit ae9e2a
 *
Packit ae9e2a
 * @return 0 or an error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_note_create(
Packit ae9e2a
	git_oid *out,
Packit ae9e2a
	git_repository *repo,
Packit ae9e2a
	const char *notes_ref,
Packit ae9e2a
	const git_signature *author,
Packit ae9e2a
	const git_signature *committer,
Packit ae9e2a
	const git_oid *oid,
Packit ae9e2a
	const char *note,
Packit ae9e2a
	int force);
Packit ae9e2a
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Remove the note for an object
Packit ae9e2a
 *
Packit ae9e2a
 * @param repo repository where the note lives
Packit ae9e2a
 * @param notes_ref canonical name of the reference to use (optional);
Packit ae9e2a
 *					defaults to "refs/notes/commits"
Packit ae9e2a
 * @param author signature of the notes commit author
Packit ae9e2a
 * @param committer signature of the notes commit committer
Packit ae9e2a
 * @param oid OID of the git object to remove the note from
Packit ae9e2a
 *
Packit ae9e2a
 * @return 0 or an error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_note_remove(
Packit ae9e2a
	git_repository *repo,
Packit ae9e2a
	const char *notes_ref,
Packit ae9e2a
	const git_signature *author,
Packit ae9e2a
	const git_signature *committer,
Packit ae9e2a
	const git_oid *oid);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Free a git_note object
Packit ae9e2a
 *
Packit ae9e2a
 * @param note git_note object
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(void) git_note_free(git_note *note);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Get the default notes reference for a repository
Packit ae9e2a
 *
Packit ae9e2a
 * @param out buffer in which to store the name of the default notes reference
Packit ae9e2a
 * @param repo The Git repository
Packit ae9e2a
 *
Packit ae9e2a
 * @return 0 or an error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_note_default_ref(git_buf *out, git_repository *repo);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Loop over all the notes within a specified namespace
Packit ae9e2a
 * and issue a callback for each one.
Packit ae9e2a
 *
Packit ae9e2a
 * @param repo Repository where to find the notes.
Packit ae9e2a
 *
Packit ae9e2a
 * @param notes_ref Reference to read from (optional); defaults to
Packit ae9e2a
 *        "refs/notes/commits".
Packit ae9e2a
 *
Packit ae9e2a
 * @param note_cb Callback to invoke per found annotation.  Return non-zero
Packit ae9e2a
 *        to stop looping.
Packit ae9e2a
 *
Packit ae9e2a
 * @param payload Extra parameter to callback function.
Packit ae9e2a
 *
Packit ae9e2a
 * @return 0 on success, non-zero callback return value, or error code
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_note_foreach(
Packit ae9e2a
	git_repository *repo,
Packit ae9e2a
	const char *notes_ref,
Packit ae9e2a
	git_note_foreach_cb note_cb,
Packit ae9e2a
	void *payload);
Packit ae9e2a
Packit ae9e2a
/** @} */
Packit ae9e2a
GIT_END_DECL
Packit ae9e2a
#endif