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
26 /** For merge commits, the "mainline" is treated as the parent. */
27 unsigned int mainline
;
29 git_merge_options merge_opts
;
30 git_checkout_options checkout_opts
;
33 #define GIT_REVERT_OPTIONS_VERSION 1
34 #define GIT_REVERT_OPTIONS_INIT {GIT_REVERT_OPTIONS_VERSION, 0, GIT_MERGE_OPTIONS_INIT, GIT_CHECKOUT_OPTIONS_INIT}
37 * Initializes a `git_revert_options` with default values. Equivalent to
38 * creating an instance with GIT_REVERT_OPTIONS_INIT.
40 * @param opts the `git_revert_options` struct to initialize
41 * @param version Version of struct; pass `GIT_REVERT_OPTIONS_VERSION`
42 * @return Zero on success; -1 on failure.
44 GIT_EXTERN(int) git_revert_init_options(
45 git_revert_options
*opts
,
46 unsigned int version
);
49 * Reverts the given commit against the given "our" commit, producing an
50 * index that reflects the result of the revert.
52 * The returned index must be freed explicitly with `git_index_free`.
54 * @param out pointer to store the index result in
55 * @param repo the repository that contains the given commits
56 * @param revert_commit the commit to revert
57 * @param our_commit the commit to revert against (eg, HEAD)
58 * @param mainline the parent of the revert commit, if it is a merge
59 * @param merge_options the merge options (or null for defaults)
60 * @return zero on success, -1 on failure.
62 GIT_EXTERN(int) git_revert_commit(
65 git_commit
*revert_commit
,
66 git_commit
*our_commit
,
67 unsigned int mainline
,
68 const git_merge_options
*merge_options
);
71 * Reverts the given commit, producing changes in the working directory.
73 * @param repo the repository to revert
74 * @param commit the commit to revert
75 * @param given_opts merge flags
76 * @return zero on success, -1 on failure.
78 GIT_EXTERN(int) git_revert(
81 const git_revert_options
*given_opts
);