]> git.proxmox.com Git - libgit2.git/blame - include/git2/revert.h
New upstream version 0.28.1+dfsg.1
[libgit2.git] / include / git2 / revert.h
CommitLineData
300d192f
ET
1/*
2 * Copyright (C) the libgit2 contributors. All rights reserved.
3 *
4 * This file is part of libgit2, distributed under the GNU GPL v2 with
5 * a Linking Exception. For full terms see the included COPYING file.
6 */
7#ifndef INCLUDE_git_revert_h__
8#define INCLUDE_git_revert_h__
9
10#include "common.h"
11#include "types.h"
12#include "merge.h"
13
14/**
15 * @file git2/revert.h
16 * @brief Git revert routines
17 * @defgroup git_revert Git revert routines
18 * @ingroup Git
19 * @{
20 */
21GIT_BEGIN_DECL
22
a295bd2d
CMN
23/**
24 * Options for revert
25 */
300d192f
ET
26typedef struct {
27 unsigned int version;
28
29 /** For merge commits, the "mainline" is treated as the parent. */
30 unsigned int mainline;
31
c03e8c22
BC
32 git_merge_options merge_opts; /**< Options for the merging */
33 git_checkout_options checkout_opts; /**< Options for the checkout */
aa17c3c6 34} git_revert_options;
300d192f 35
aa17c3c6 36#define GIT_REVERT_OPTIONS_VERSION 1
5aa2ac6d 37#define GIT_REVERT_OPTIONS_INIT {GIT_REVERT_OPTIONS_VERSION, 0, GIT_MERGE_OPTIONS_INIT, GIT_CHECKOUT_OPTIONS_INIT}
300d192f 38
b9f81997 39/**
ac3d33df
JK
40 * Initialize git_revert_options structure
41 *
aa17c3c6 42 * Initializes a `git_revert_options` with default values. Equivalent to
ac3d33df 43 * creating an instance with `GIT_REVERT_OPTIONS_INIT`.
b9f81997 44 *
ac3d33df
JK
45 * @param opts The `git_revert_options` struct to initialize.
46 * @param version The struct version; pass `GIT_REVERT_OPTIONS_VERSION`.
b9f81997
MB
47 * @return Zero on success; -1 on failure.
48 */
bc91347b
RB
49GIT_EXTERN(int) git_revert_init_options(
50 git_revert_options *opts,
51 unsigned int version);
b9f81997 52
300d192f 53/**
eac938d9
ET
54 * Reverts the given commit against the given "our" commit, producing an
55 * index that reflects the result of the revert.
56 *
57 * The returned index must be freed explicitly with `git_index_free`.
58 *
59 * @param out pointer to store the index result in
60 * @param repo the repository that contains the given commits
61 * @param revert_commit the commit to revert
62 * @param our_commit the commit to revert against (eg, HEAD)
63 * @param mainline the parent of the revert commit, if it is a merge
31b0cb51 64 * @param merge_options the merge options (or null for defaults)
eac938d9
ET
65 * @return zero on success, -1 on failure.
66 */
4e813a8b 67GIT_EXTERN(int) git_revert_commit(
eac938d9
ET
68 git_index **out,
69 git_repository *repo,
70 git_commit *revert_commit,
71 git_commit *our_commit,
72 unsigned int mainline,
5aa2ac6d 73 const git_merge_options *merge_options);
eac938d9
ET
74
75/**
f8263472 76 * Reverts the given commit, producing changes in the index and working directory.
eac938d9
ET
77 *
78 * @param repo the repository to revert
31b0cb51 79 * @param commit the commit to revert
21d4a378 80 * @param given_opts the revert options (or null for defaults)
eac938d9
ET
81 * @return zero on success, -1 on failure.
82 */
300d192f
ET
83GIT_EXTERN(int) git_revert(
84 git_repository *repo,
85 git_commit *commit,
aa17c3c6 86 const git_revert_options *given_opts);
300d192f
ET
87
88/** @} */
89GIT_END_DECL
90#endif
91