1 module deimos.git2.merge;
2 
3 import deimos.git2.annotated_commit;
4 import deimos.git2.common;
5 import deimos.git2.checkout;
6 import deimos.git2.diff;
7 import deimos.git2.index;
8 import deimos.git2.oid;
9 import deimos.git2.oidarray;
10 import deimos.git2.util;
11 import deimos.git2.types;
12 
13 extern (C):
14 
15 struct git_merge_file_input {
16     uint version_;
17     const(char)* ptr;
18     size_t size;
19     const(char)* path;
20     uint mode;
21 }
22 
23 enum GIT_MERGE_FILE_INPUT_VERSION = 1;
24 enum git_merge_file_input GIT_MERGE_FILE_INPUT_INIT = {GIT_MERGE_FILE_INPUT_VERSION};
25 
26 int git_merge_file_init_input(git_merge_file_input* opts, uint version_);
27 
28 enum git_merge_flag_t {
29     GIT_MERGE_FIND_RENAMES = (1 << 0),
30     GIT_MERGE_FAIL_ON_CONFLICT = (1 << 1),
31     GIT_MERGE_SKIP_REUC = (1 << 2),
32     GIT_MERGE_NO_RECURSIVE = (1 << 3),
33 }
34 mixin _ExportEnumMembers!git_merge_flag_t;
35 
36 enum git_merge_file_favor_t {
37     GIT_MERGE_FILE_FAVOR_NORMAL = 0,
38     GIT_MERGE_FILE_FAVOR_OURS = 1,
39     GIT_MERGE_FILE_FAVOR_THEIRS = 2,
40     GIT_MERGE_FILE_FAVOR_UNION = 3,
41 }
42 mixin _ExportEnumMembers!git_merge_file_favor_t;
43 
44 enum git_merge_file_flag_t {
45     GIT_MERGE_FILE_DEFAULT = 0,
46     GIT_MERGE_FILE_STYLE_MERGE = (1 << 0),
47     GIT_MERGE_FILE_STYLE_DIFF3 = (1 << 1),
48     GIT_MERGE_FILE_SIMPLIFY_ALNUM = (1 << 2),
49     GIT_MERGE_FILE_IGNORE_WHITESPACE = (1 << 3),
50     GIT_MERGE_FILE_IGNORE_WHITESPACE_CHANGE = (1 << 4),
51     GIT_MERGE_FILE_IGNORE_WHITESPACE_EOL = (1 << 5),
52     GIT_MERGE_FILE_DIFF_PATIENCE = (1 << 6),
53     GIT_MERGE_FILE_DIFF_MINIMAL = (1 << 7),
54 }
55 mixin _ExportEnumMembers!git_merge_file_flag_t;
56 struct git_merge_file_options {
57     uint version_;
58     const(char)* ancestor_label;
59     const(char)* our_label;
60     const(char)* their_label;
61     git_merge_file_favor_t favor;
62     git_merge_file_flag_t flags;
63 }
64 
65 enum GIT_MERGE_FILE_OPTIONS_VERSION = 1;
66 enum git_merge_file_options GIT_MERGE_FILE_OPTIONS_INIT = {GIT_MERGE_FILE_OPTIONS_VERSION};
67 
68 int git_merge_file_init_options(git_merge_file_options* opts, uint version_);
69 struct git_merge_file_result {
70     uint automergeable;
71     const(char)* path;
72     uint mode;
73     const(char)* ptr;
74     size_t len;
75 }
76 
77 struct git_merge_options {
78     uint version_;
79     git_merge_flag_t flags;
80     uint rename_threshold;
81     uint target_limit;
82     git_diff_similarity_metric* metric;
83     uint recursion_limit;
84     const(char)* default_driver;
85     git_merge_file_favor_t file_favor;
86     git_merge_file_flag_t file_flags;
87 }
88 
89 enum GIT_MERGE_OPTIONS_VERSION = 1;
90 enum git_merge_options GIT_MERGE_OPTIONS_INIT = {GIT_MERGE_OPTIONS_VERSION};
91 
92 int git_merge_init_options(git_merge_options *opts, uint version_);
93 
94 enum git_merge_flags_t {
95 	GIT_MERGE_NO_FASTFORWARD      = 1,
96 	GIT_MERGE_FASTFORWARD_ONLY    = 2,
97 }
98 
99 enum git_merge_analysis_t {
100     GIT_MERGE_ANALYSIS_NONE = 0,
101     GIT_MERGE_ANALYSIS_NORMAL = (1 << 0),
102     GIT_MERGE_ANALYSIS_UP_TO_DATE = (1 << 1),
103     GIT_MERGE_ANALYSIS_FASTFORWARD = (1 << 2),
104     GIT_MERGE_ANALYSIS_UNBORN = (1 << 3),
105 }
106 
107 enum git_merge_preference_t{
108     GIT_MERGE_PREFERENCE_NONE = 0,
109     GIT_MERGE_PREFERENCE_NO_FASTFORWARD = (1 << 0),
110     GIT_MERGE_PREFERENCE_FASTFORWARD_ONLY = (1 << 1),
111 }
112 
113 int git_merge_analysis(
114     git_merge_analysis_t* analysis_out,
115     git_merge_preference_t* preference_out,
116     git_repository* repo,
117     const(git_annotated_commit)** their_heads,
118     size_t their_heads_len,
119 );
120 
121 
122 int git_merge_base(
123 	git_oid *out_,
124 	git_repository *repo,
125 	const(git_oid)* one,
126 	const(git_oid)* two);
127 
128 int git_merge_bases(
129 	git_oidarray *out_,
130     git_repository *repo,
131     const(git_oid)* one,
132     const(git_oid)* two);
133 
134 int git_merge_base_many(
135 	git_oid *out_,
136 	git_repository *repo,
137 	size_t length,
138 	const(git_oid)* input_array);
139 int git_merge_bases_many(
140     git_oidarray* out_,
141     git_repository* repo,
142     size_t length,
143     const(git_oid)[] input_array);
144 int git_merge_base_octopus(
145     git_oid* out_,
146     git_repository* repo,
147     size_t length,
148     const(git_oid)[] input_array);
149 int git_merge_file(
150     git_merge_file_result* out_,
151     const(git_merge_file_input)* ancestor,
152     const(git_merge_file_input)* ours,
153     const(git_merge_file_input)* theirs,
154     const(git_merge_file_options)* opts);
155 int git_merge_file_from_index(
156     git_merge_file_result* out_,
157     git_repository *repo,
158     const(git_index_entry)* ancestor,
159     const(git_index_entry)* ours,
160     const(git_index_entry)* theirs,
161     const(git_merge_file_options)* opts);
162 
163 void git_merge_file_result_free(git_merge_file_result* result);
164 
165 int git_merge_trees(
166 	git_index **out_,
167 	git_repository *repo,
168 	const(git_tree)* ancestor_tree,
169 	const(git_tree)* our_tree,
170 	const(git_tree)* their_tree,
171 	const(git_merge_options)* opts);
172 int git_merge_commits(
173     git_index** out_,
174     git_repository* repo,
175     const(git_commit)* our_commit,
176     const(git_commit)* their_commit,
177     const(git_merge_options)* opts);
178 
179 int git_merge(
180     git_repository* repo,
181     const(git_annotated_commit)** their_heads,
182     size_t their_heads_len,
183     const(git_merge_options)* merge_opts,
184     const(git_checkout_options)* checkout_opts);