Blame include/git2/revert.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_revert_h__
Packit ae9e2a
#define INCLUDE_git_revert_h__
Packit ae9e2a
Packit ae9e2a
#include "common.h"
Packit ae9e2a
#include "types.h"
Packit ae9e2a
#include "merge.h"
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * @file git2/revert.h
Packit ae9e2a
 * @brief Git revert routines
Packit ae9e2a
 * @defgroup git_revert Git revert routines
Packit ae9e2a
 * @ingroup Git
Packit ae9e2a
 * @{
Packit ae9e2a
 */
Packit ae9e2a
GIT_BEGIN_DECL
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Options for revert
Packit ae9e2a
 */
Packit ae9e2a
typedef struct {
Packit ae9e2a
	unsigned int version;
Packit ae9e2a
Packit ae9e2a
	/** For merge commits, the "mainline" is treated as the parent. */
Packit ae9e2a
	unsigned int mainline;
Packit ae9e2a
Packit ae9e2a
	git_merge_options merge_opts; /**< Options for the merging */
Packit ae9e2a
	git_checkout_options checkout_opts; /**< Options for the checkout */
Packit ae9e2a
} git_revert_options;
Packit ae9e2a
Packit ae9e2a
#define GIT_REVERT_OPTIONS_VERSION 1
Packit ae9e2a
#define GIT_REVERT_OPTIONS_INIT {GIT_REVERT_OPTIONS_VERSION, 0, GIT_MERGE_OPTIONS_INIT, GIT_CHECKOUT_OPTIONS_INIT}
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Initializes a `git_revert_options` with default values. Equivalent to
Packit ae9e2a
 * creating an instance with GIT_REVERT_OPTIONS_INIT.
Packit ae9e2a
 *
Packit ae9e2a
 * @param opts the `git_revert_options` struct to initialize
Packit ae9e2a
 * @param version Version of struct; pass `GIT_REVERT_OPTIONS_VERSION`
Packit ae9e2a
 * @return Zero on success; -1 on failure.
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_revert_init_options(
Packit ae9e2a
	git_revert_options *opts,
Packit ae9e2a
	unsigned int version);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Reverts the given commit against the given "our" commit, producing an
Packit ae9e2a
 * index that reflects the result of the revert.
Packit ae9e2a
 *
Packit ae9e2a
 * The returned index must be freed explicitly with `git_index_free`.
Packit ae9e2a
 *
Packit ae9e2a
 * @param out pointer to store the index result in
Packit ae9e2a
 * @param repo the repository that contains the given commits
Packit ae9e2a
 * @param revert_commit the commit to revert
Packit ae9e2a
 * @param our_commit the commit to revert against (eg, HEAD)
Packit ae9e2a
 * @param mainline the parent of the revert commit, if it is a merge
Packit ae9e2a
 * @param merge_options the merge options (or null for defaults)
Packit ae9e2a
 * @return zero on success, -1 on failure.
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_revert_commit(
Packit ae9e2a
	git_index **out,
Packit ae9e2a
	git_repository *repo,
Packit ae9e2a
	git_commit *revert_commit,
Packit ae9e2a
	git_commit *our_commit,
Packit ae9e2a
	unsigned int mainline,
Packit ae9e2a
	const git_merge_options *merge_options);
Packit ae9e2a
Packit ae9e2a
/**
Packit ae9e2a
 * Reverts the given commit, producing changes in the index and working directory.
Packit ae9e2a
 *
Packit ae9e2a
 * @param repo the repository to revert
Packit ae9e2a
 * @param commit the commit to revert
Packit ae9e2a
 * @param given_opts the revert options (or null for defaults)
Packit ae9e2a
 * @return zero on success, -1 on failure.
Packit ae9e2a
 */
Packit ae9e2a
GIT_EXTERN(int) git_revert(
Packit ae9e2a
	git_repository *repo,
Packit ae9e2a
	git_commit *commit,
Packit ae9e2a
	const git_revert_options *given_opts);
Packit ae9e2a
Packit ae9e2a
/** @} */
Packit ae9e2a
GIT_END_DECL
Packit ae9e2a
#endif
Packit ae9e2a