Blame include/git2/notes.h

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