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 /**
8  * License: GPL-2.0(Linking Exception)
9  */
10 module libgit2.revert;
11 
12 
13 private static import libgit2.checkout;
14 private static import libgit2.merge;
15 private static import libgit2.types;
16 private import libgit2.common: GIT_EXTERN;
17 
18 /*
19  * @file git2/revert.h
20  * @brief Git revert routines
21  * @defgroup git_revert Git revert routines
22  * @ingroup Git
23  * @{
24  */
25 extern (C):
26 nothrow @nogc:
27 public:
28 
29 /**
30  * Options for revert
31  */
32 struct git_revert_options
33 {
34 	uint version_;
35 
36 	/**
37 	 * For merge commits, the "mainline" is treated as the parent.
38 	 */
39 	uint mainline;
40 
41 	/**
42 	 * Options for the merging
43 	 */
44 	libgit2.merge.git_merge_options merge_opts;
45 
46 	/**
47 	 * Options for the checkout
48 	 */
49 	libgit2.checkout.git_checkout_options checkout_opts;
50 }
51 
52 enum GIT_REVERT_OPTIONS_VERSION = 1;
53 
54 pragma(inline, true)
55 pure nothrow @safe @nogc @live
56 .git_revert_options GIT_REVERT_OPTIONS_INIT()
57 
58 	do
59 	{
60 		.git_revert_options OUTPUT =
61 		{
62 			version_: .GIT_REVERT_OPTIONS_VERSION,
63 			mainline: 0,
64 			merge_opts: libgit2.merge.GIT_MERGE_OPTIONS_INIT(),
65 			checkout_opts: libgit2.checkout.GIT_CHECKOUT_OPTIONS_INIT(),
66 		};
67 
68 		return OUTPUT;
69 	}
70 
71 /**
72  * Initialize git_revert_options structure
73  *
74  * Initializes a `git_revert_options` with default values. Equivalent to
75  * creating an instance with `GIT_REVERT_OPTIONS_INIT`.
76  *
77  * Params:
78  *      opts = The `git_revert_options` struct to initialize.
79  *      version_ = The struct version; pass `GIT_REVERT_OPTIONS_VERSION`.
80  *
81  * Returns: Zero on success; -1 on failure.
82  */
83 @GIT_EXTERN
84 int git_revert_options_init(.git_revert_options* opts, uint version_);
85 
86 /**
87  * Reverts the given commit against the given "our" commit, producing an
88  * index that reflects the result of the revert.
89  *
90  * The returned index must be freed explicitly with `git_index_free`.
91  *
92  * Params:
93  *      out_ = pointer to store the index result in
94  *      repo = the repository that contains the given commits
95  *      revert_commit = the commit to revert
96  *      our_commit = the commit to revert against (eg, HEAD)
97  *      mainline = the parent of the revert commit, if it is a merge
98  *      merge_options = the merge options (or null for defaults)
99  *
100  * Returns: zero on success, -1 on failure.
101  */
102 @GIT_EXTERN
103 int git_revert_commit(libgit2.types.git_index** out_, libgit2.types.git_repository* repo, libgit2.types.git_commit* revert_commit, libgit2.types.git_commit* our_commit, uint mainline, const (libgit2.merge.git_merge_options)* merge_options);
104 
105 /**
106  * Reverts the given commit, producing changes in the index and working
107  * directory.
108  *
109  * Params:
110  *      repo = the repository to revert
111  *      commit = the commit to revert
112  *      given_opts = the revert options (or null for defaults)
113  *
114  * Returns: zero on success, -1 on failure.
115  */
116 @GIT_EXTERN
117 int git_revert(libgit2.types.git_repository* repo, libgit2.types.git_commit* commit, const (.git_revert_options)* given_opts);
118 
119 /* @} */