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.cherrypick;
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/cherrypick.h
16  * @brief Git cherry-pick routines
17  * @defgroup git_cherrypick Git cherry-pick routines
18  * @ingroup Git
19  * @{
20  */
21 extern (C):
22 nothrow @nogc:
23 public:
24 
25 /**
26  * Cherry-pick options
27  */
28 struct git_cherrypick_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_CHERRYPICK_OPTIONS_VERSION = 1;
49 
50 pragma(inline, true)
51 pure nothrow @safe @nogc
52 .git_cherrypick_options GIT_CHERRYPICK_OPTIONS_INIT()
53 
54 	do
55 	{
56 		.git_cherrypick_options OUTPUT =
57 		{
58 			version_: .GIT_CHERRYPICK_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_cherrypick_options structure
69  *
70  * Initializes a `git_cherrypick_options` with default values. Equivalent to creating
71  * an instance with GIT_CHERRYPICK_OPTIONS_INIT.
72  *
73  * @param opts The `git_cherrypick_options` struct to initialize.
74  * @param version The struct version; pass `GIT_CHERRYPICK_OPTIONS_VERSION`.
75  * @return Zero on success; -1 on failure.
76  */
77 //GIT_EXTERN
78 int git_cherrypick_options_init(.git_cherrypick_options* opts, uint version_);
79 
80 /**
81  * Cherry-picks the given commit against the given "our" commit, producing an
82  * index that reflects the result of the cherry-pick.
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 cherrypick_commit the commit to cherry-pick
89  * @param our_commit the commit to cherry-pick against (eg, HEAD)
90  * @param mainline the parent of the `cherrypick_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_cherrypick_commit(libgit2_d.types.git_index** out_, libgit2_d.types.git_repository* repo, libgit2_d.types.git_commit* cherrypick_commit, libgit2_d.types.git_commit* our_commit, uint mainline, const (libgit2_d.merge.git_merge_options)* merge_options);
96 
97 /**
98  * Cherry-pick the given commit, producing changes in the index and working
99  * directory.
100  *
101  * @param repo the repository to cherry-pick
102  * @param commit the commit to cherry-pick
103  * @param cherrypick_options the cherry-pick options (or null for defaults)
104  * @return zero on success, -1 on failure.
105  */
106 //GIT_EXTERN
107 int git_cherrypick(libgit2_d.types.git_repository* repo, libgit2_d.types.git_commit* commit, const (.git_cherrypick_options)* cherrypick_options);
108 
109 /** @} */