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