2 * Copyright (C) the libgit2 contributors. All rights reserved.
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.
7 #ifndef INCLUDE_git_revert_h__
8 #define INCLUDE_git_revert_h__
16 * @brief Git revert routines
17 * @defgroup git_revert Git revert routines
29 /** For merge commits, the "mainline" is treated as the parent. */
30 unsigned int mainline
;
32 git_merge_options merge_opts
; /**< Options for the merging */
33 git_checkout_options checkout_opts
; /**< Options for the checkout */
36 #define GIT_REVERT_OPTIONS_VERSION 1
37 #define GIT_REVERT_OPTIONS_INIT {GIT_REVERT_OPTIONS_VERSION, 0, GIT_MERGE_OPTIONS_INIT, GIT_CHECKOUT_OPTIONS_INIT}
40 * Initializes a `git_revert_options` with default values. Equivalent to
41 * creating an instance with GIT_REVERT_OPTIONS_INIT.
43 * @param opts the `git_revert_options` struct to initialize
44 * @param version Version of struct; pass `GIT_REVERT_OPTIONS_VERSION`
45 * @return Zero on success; -1 on failure.
47 GIT_EXTERN(int) git_revert_init_options(
48 git_revert_options
*opts
,
49 unsigned int version
);
52 * Reverts the given commit against the given "our" commit, producing an
53 * index that reflects the result of the revert.
55 * The returned index must be freed explicitly with `git_index_free`.
57 * @param out pointer to store the index result in
58 * @param repo the repository that contains the given commits
59 * @param revert_commit the commit to revert
60 * @param our_commit the commit to revert against (eg, HEAD)
61 * @param mainline the parent of the revert commit, if it is a merge
62 * @param merge_options the merge options (or null for defaults)
63 * @return zero on success, -1 on failure.
65 GIT_EXTERN(int) git_revert_commit(
68 git_commit
*revert_commit
,
69 git_commit
*our_commit
,
70 unsigned int mainline
,
71 const git_merge_options
*merge_options
);
74 * Reverts the given commit, producing changes in the index and working directory.
76 * @param repo the repository to revert
77 * @param commit the commit to revert
78 * @param given_opts the revert options (or null for defaults)
79 * @return zero on success, -1 on failure.
81 GIT_EXTERN(int) git_revert(
84 const git_revert_options
*given_opts
);