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.merge;
8 
9 
10 private static import libgit2_d.checkout;
11 private static import libgit2_d.diff;
12 private static import libgit2_d.index;
13 private static import libgit2_d.oid;
14 private static import libgit2_d.oidarray;
15 private static import libgit2_d.types;
16 
17 /**
18  * @file git2/merge.h
19  * @brief Git merge routines
20  * @defgroup git_merge Git merge routines
21  * @ingroup Git
22  * @{
23  */
24 extern (C):
25 nothrow @nogc:
26 public:
27 
28 /**
29  * The file inputs to `git_merge_file`.  Callers should populate the
30  * `git_merge_file_input` structure with descriptions of the files in
31  * each side of the conflict for use in producing the merge file.
32  */
33 struct git_merge_file_input
34 {
35 	uint version_;
36 
37 	/**
38 	 * Pointer to the contents of the file.
39 	 */
40 	const (char)* ptr_;
41 
42 	/**
43 	 * Size of the contents pointed to in `ptr_`.
44 	 */
45 	size_t size;
46 
47 	/**
48 	 * File name of the conflicted file, or `null` to not merge the path.
49 	 */
50 	const (char)* path;
51 
52 	/**
53 	 * File mode of the conflicted file, or `0` to not merge the mode.
54 	 */
55 	uint mode;
56 }
57 
58 enum GIT_MERGE_FILE_INPUT_VERSION = 1;
59 
60 pragma(inline, true)
61 pure nothrow @safe @nogc
62 .git_merge_file_input GIT_MERGE_FILE_INPUT_INIT()
63 
64 	do
65 	{
66 		.git_merge_file_input OUTPUT =
67 		{
68 			version_: .GIT_MERGE_FILE_INPUT_VERSION,
69 		};
70 
71 		return OUTPUT;
72 	}
73 
74 /**
75  * Initializes a `git_merge_file_input` with default values. Equivalent to
76  * creating an instance with GIT_MERGE_FILE_INPUT_INIT.
77  *
78  * Params:
79  *      opts = the `git_merge_file_input` instance to initialize.
80  *      version_ = the version of the struct; you should pass `GIT_MERGE_FILE_INPUT_VERSION` here.
81  *
82  * Returns: Zero on success; -1 on failure.
83  */
84 //GIT_EXTERN
85 int git_merge_file_input_init(.git_merge_file_input* opts, uint version_);
86 
87 /**
88  * Flags for `git_merge` options.  A combination of these flags can be
89  * passed in via the `flags` value in the `git_merge_options`.
90  */
91 enum git_merge_flag_t
92 {
93 	/**
94 	 * Detect renames that occur between the common ancestor and the "ours"
95 	 * side or the common ancestor and the "theirs" side.  This will enable
96 	 * the ability to merge between a modified and renamed file.
97 	 */
98 	GIT_MERGE_FIND_RENAMES = 1 << 0,
99 
100 	/**
101 	 * If a conflict occurs, exit immediately instead of attempting to
102 	 * continue resolving conflicts.  The merge operation will fail with
103 	 * git_error_code.GIT_EMERGECONFLICT and no index will be returned.
104 	 */
105 	GIT_MERGE_FAIL_ON_CONFLICT = 1 << 1,
106 
107 	/**
108 	 * Do not write the REUC extension on the generated index
109 	 */
110 	GIT_MERGE_SKIP_REUC = 1 << 2,
111 
112 	/**
113 	 * If the commits being merged have multiple merge bases, do not build
114 	 * a recursive merge base (by merging the multiple merge bases),
115 	 * instead simply use the first base.  This flag provides a similar
116 	 * merge base to `git-merge-resolve`.
117 	 */
118 	GIT_MERGE_NO_RECURSIVE = 1 << 3,
119 }
120 
121 //Declaration name in C language
122 enum
123 {
124 	GIT_MERGE_FIND_RENAMES = .git_merge_flag_t.GIT_MERGE_FIND_RENAMES,
125 	GIT_MERGE_FAIL_ON_CONFLICT = .git_merge_flag_t.GIT_MERGE_FAIL_ON_CONFLICT,
126 	GIT_MERGE_SKIP_REUC = .git_merge_flag_t.GIT_MERGE_SKIP_REUC,
127 	GIT_MERGE_NO_RECURSIVE = .git_merge_flag_t.GIT_MERGE_NO_RECURSIVE,
128 }
129 
130 /**
131  * Merge file favor options for `git_merge_options` instruct the file-level
132  * merging functionality how to deal with conflicting regions of the files.
133  */
134 enum git_merge_file_favor_t
135 {
136 	/**
137 	 * When a region of a file is changed in both branches, a conflict
138 	 * will be recorded in the index so that `git_checkout` can produce
139 	 * a merge file with conflict markers in the working directory.
140 	 * This is the default.
141 	 */
142 	GIT_MERGE_FILE_FAVOR_NORMAL = 0,
143 
144 	/**
145 	 * When a region of a file is changed in both branches, the file
146 	 * created in the index will contain the "ours" side of any conflicting
147 	 * region.  The index will not record a conflict.
148 	 */
149 	GIT_MERGE_FILE_FAVOR_OURS = 1,
150 
151 	/**
152 	 * When a region of a file is changed in both branches, the file
153 	 * created in the index will contain the "theirs" side of any conflicting
154 	 * region.  The index will not record a conflict.
155 	 */
156 	GIT_MERGE_FILE_FAVOR_THEIRS = 2,
157 
158 	/**
159 	 * When a region of a file is changed in both branches, the file
160 	 * created in the index will contain each unique line from each side,
161 	 * which has the result of combining both files.  The index will not
162 	 * record a conflict.
163 	 */
164 	GIT_MERGE_FILE_FAVOR_UNION = 3,
165 }
166 
167 //Declaration name in C language
168 enum
169 {
170 	GIT_MERGE_FILE_FAVOR_NORMAL = .git_merge_file_favor_t.GIT_MERGE_FILE_FAVOR_NORMAL,
171 	GIT_MERGE_FILE_FAVOR_OURS = .git_merge_file_favor_t.GIT_MERGE_FILE_FAVOR_OURS,
172 	GIT_MERGE_FILE_FAVOR_THEIRS = .git_merge_file_favor_t.GIT_MERGE_FILE_FAVOR_THEIRS,
173 	GIT_MERGE_FILE_FAVOR_UNION = .git_merge_file_favor_t.GIT_MERGE_FILE_FAVOR_UNION,
174 }
175 
176 /**
177  * File merging flags
178  */
179 enum git_merge_file_flag_t
180 {
181 	/**
182 	 * Defaults
183 	 */
184 	GIT_MERGE_FILE_DEFAULT = 0,
185 
186 	/**
187 	 * Create standard conflicted merge files
188 	 */
189 	GIT_MERGE_FILE_STYLE_MERGE = 1 << 0,
190 
191 	/**
192 	 * Create diff3-style files
193 	 */
194 	GIT_MERGE_FILE_STYLE_DIFF3 = 1 << 1,
195 
196 	/**
197 	 * Condense non-alphanumeric regions for simplified diff file
198 	 */
199 	GIT_MERGE_FILE_SIMPLIFY_ALNUM = 1 << 2,
200 
201 	/**
202 	 * Ignore all whitespace
203 	 */
204 	GIT_MERGE_FILE_IGNORE_WHITESPACE = 1 << 3,
205 
206 	/**
207 	 * Ignore changes in amount of whitespace
208 	 */
209 	GIT_MERGE_FILE_IGNORE_WHITESPACE_CHANGE = 1 << 4,
210 
211 	/**
212 	 * Ignore whitespace at end of line
213 	 */
214 	GIT_MERGE_FILE_IGNORE_WHITESPACE_EOL = 1 << 5,
215 
216 	/**
217 	 * Use the "patience diff" algorithm
218 	 */
219 	GIT_MERGE_FILE_DIFF_PATIENCE = 1 << 6,
220 
221 	/**
222 	 * Take extra time to find minimal diff
223 	 */
224 	GIT_MERGE_FILE_DIFF_MINIMAL = 1 << 7,
225 }
226 
227 //Declaration name in C language
228 enum
229 {
230 	GIT_MERGE_FILE_DEFAULT = .git_merge_file_flag_t.GIT_MERGE_FILE_DEFAULT,
231 	GIT_MERGE_FILE_STYLE_MERGE = .git_merge_file_flag_t.GIT_MERGE_FILE_STYLE_MERGE,
232 	GIT_MERGE_FILE_STYLE_DIFF3 = .git_merge_file_flag_t.GIT_MERGE_FILE_STYLE_DIFF3,
233 	GIT_MERGE_FILE_SIMPLIFY_ALNUM = .git_merge_file_flag_t.GIT_MERGE_FILE_SIMPLIFY_ALNUM,
234 	GIT_MERGE_FILE_IGNORE_WHITESPACE = .git_merge_file_flag_t.GIT_MERGE_FILE_IGNORE_WHITESPACE,
235 	GIT_MERGE_FILE_IGNORE_WHITESPACE_CHANGE = .git_merge_file_flag_t.GIT_MERGE_FILE_IGNORE_WHITESPACE_CHANGE,
236 	GIT_MERGE_FILE_IGNORE_WHITESPACE_EOL = .git_merge_file_flag_t.GIT_MERGE_FILE_IGNORE_WHITESPACE_EOL,
237 	GIT_MERGE_FILE_DIFF_PATIENCE = .git_merge_file_flag_t.GIT_MERGE_FILE_DIFF_PATIENCE,
238 	GIT_MERGE_FILE_DIFF_MINIMAL = .git_merge_file_flag_t.GIT_MERGE_FILE_DIFF_MINIMAL,
239 }
240 
241 enum GIT_MERGE_CONFLICT_MARKER_SIZE = 7;
242 
243 /**
244  * Options for merging a file
245  */
246 struct git_merge_file_options
247 {
248 	uint version_;
249 
250 	/**
251 	 * Label for the ancestor file side of the conflict which will be prepended
252 	 * to labels in diff3-format merge files.
253 	 */
254 	const (char)* ancestor_label;
255 
256 	/**
257 	 * Label for our file side of the conflict which will be prepended
258 	 * to labels in merge files.
259 	 */
260 	const (char)* our_label;
261 
262 	/**
263 	 * Label for their file side of the conflict which will be prepended
264 	 * to labels in merge files.
265 	 */
266 	const (char)* their_label;
267 
268 	/**
269 	 * The file to favor in region conflicts.
270 	 */
271 	.git_merge_file_favor_t favor;
272 
273 	/**
274 	 * see `git_merge_file_flag_t` above
275 	 */
276 	uint flags;
277 
278 	/**
279 	 * The size of conflict markers (eg, "<<<<<<<").  Default is
280 	 * GIT_MERGE_CONFLICT_MARKER_SIZE.
281 	 */
282 	ushort marker_size;
283 }
284 
285 enum GIT_MERGE_FILE_OPTIONS_VERSION = 1;
286 
287 pragma(inline, true)
288 pure nothrow @safe @nogc
289 .git_merge_file_options GIT_MERGE_FILE_OPTIONS_INIT()
290 
291 	do
292 	{
293 		.git_merge_file_options OUTPUT =
294 		{
295 			version_: .GIT_MERGE_FILE_OPTIONS_VERSION,
296 		};
297 
298 		return OUTPUT;
299 	}
300 
301 /**
302  * Initialize git_merge_file_options structure
303  *
304  * Initializes a `git_merge_file_options` with default values. Equivalent to
305  * creating an instance with `GIT_MERGE_FILE_OPTIONS_INIT`.
306  *
307  * Params:
308  *      opts = The `git_merge_file_options` struct to initialize.
309  *      version = The struct version; pass `GIT_MERGE_FILE_OPTIONS_VERSION`.
310  *
311  * Returns: Zero on success; -1 on failure.
312  */
313 //GIT_EXTERN
314 int git_merge_file_options_init(.git_merge_file_options* opts, uint version_);
315 
316 /**
317  * Information about file-level merging
318  */
319 struct git_merge_file_result
320 {
321 	/**
322 	 * True if the output was automerged, false if the output contains
323 	 * conflict markers.
324 	 */
325 	uint automergeable;
326 
327 	/**
328 	 * The path that the resultant merge file should use, or null if a
329 	 * filename conflict would occur.
330 	 */
331 	const (char)* path;
332 
333 	/**
334 	 * The mode that the resultant merge file should use. 
335 	 */
336 	uint mode;
337 
338 	/**
339 	 * The contents of the merge.
340 	 */
341 	const (char)* ptr_;
342 
343 	/**
344 	 * The length of the merge contents.
345 	 */
346 	size_t len;
347 }
348 
349 /**
350  * Merging options
351  */
352 struct git_merge_options
353 {
354 	uint version_;
355 
356 	/**
357 	 * See `git_merge_flag_t` above
358 	 */
359 	uint flags;
360 
361 	/**
362 	 * Similarity to consider a file renamed (default 50).  If
363 	 * `git_merge_flag_t.GIT_MERGE_FIND_RENAMES` is enabled, added files will be compared
364 	 * with deleted files to determine their similarity.  Files that are
365 	 * more similar than the rename threshold (percentage-wise) will be
366 	 * treated as a rename.
367 	 */
368 	uint rename_threshold;
369 
370 	/**
371 	 * Maximum similarity sources to examine for renames (default 200).
372 	 * If the number of rename candidates (add / delete pairs) is greater
373 	 * than this value, inexact rename detection is aborted.
374 	 *
375 	 * This setting overrides the `merge.renameLimit` configuration value.
376 	 */
377 	uint target_limit;
378 
379 	/**
380 	 * Pluggable similarity metric; pass null to use internal metric
381 	 */
382 	libgit2_d.diff.git_diff_similarity_metric* metric;
383 
384 	/**
385 	 * Maximum number of times to merge common ancestors to build a
386 	 * virtual merge base when faced with criss-cross merges.  When this
387 	 * limit is reached, the next ancestor will simply be used instead of
388 	 * attempting to merge it.  The default is unlimited.
389 	 */
390 	uint recursion_limit;
391 
392 	/**
393 	 * Default merge driver to be used when both sides of a merge have
394 	 * changed.  The default is the `text` driver.
395 	 */
396 	const (char)* default_driver;
397 
398 	/**
399 	 * Flags for handling conflicting content, to be used with the standard
400 	 * (`text`) merge driver.
401 	 */
402 	.git_merge_file_favor_t file_favor;
403 
404 	/**
405 	 * see `git_merge_file_flag_t` above
406 	 */
407 	uint file_flags;
408 }
409 
410 enum GIT_MERGE_OPTIONS_VERSION = 1;
411 
412 pragma(inline, true)
413 pure nothrow @safe @nogc
414 .git_merge_options GIT_MERGE_OPTIONS_INIT()
415 
416 	do
417 	{
418 		.git_merge_options OUTPUT =
419 		{
420 			version_: .GIT_MERGE_OPTIONS_VERSION,
421 			flags: .git_merge_flag_t.GIT_MERGE_FIND_RENAMES,
422 		};
423 
424 		return OUTPUT;
425 	}
426 
427 /**
428  * Initialize git_merge_options structure
429  *
430  * Initializes a `git_merge_options` with default values. Equivalent to
431  * creating an instance with `GIT_MERGE_OPTIONS_INIT`.
432  *
433  * Params:
434  *      opts = The `git_merge_options` struct to initialize.
435  *      version = The struct version; pass `GIT_MERGE_OPTIONS_VERSION`.
436  *
437  * Returns: Zero on success; -1 on failure.
438  */
439 //GIT_EXTERN
440 int git_merge_options_init(.git_merge_options* opts, uint version_);
441 
442 /**
443  * The results of `git_merge_analysis` indicate the merge opportunities.
444  */
445 enum git_merge_analysis_t
446 {
447 	/**
448 	 * No merge is possible.  (Unused.)
449 	 */
450 	GIT_MERGE_ANALYSIS_NONE = 0,
451 
452 	/**
453 	 * A "normal" merge; both HEAD and the given merge input have diverged
454 	 * from their common ancestor.  The divergent commits must be merged.
455 	 */
456 	GIT_MERGE_ANALYSIS_NORMAL = 1 << 0,
457 
458 	/**
459 	 * All given merge inputs are reachable from HEAD, meaning the
460 	 * repository is up-to-date and no merge needs to be performed.
461 	 */
462 	GIT_MERGE_ANALYSIS_UP_TO_DATE = 1 << 1,
463 
464 	/**
465 	 * The given merge input is a fast-forward from HEAD and no merge
466 	 * needs to be performed.  Instead, the client can check out the
467 	 * given merge input.
468 	 */
469 	GIT_MERGE_ANALYSIS_FASTFORWARD = 1 << 2,
470 
471 	/**
472 	 * The HEAD of the current repository is "unborn" and does not point to
473 	 * a valid commit.  No merge can be performed, but the caller may wish
474 	 * to simply set HEAD to the target commit(s).
475 	 */
476 	GIT_MERGE_ANALYSIS_UNBORN = 1 << 3,
477 }
478 
479 //Declaration name in C language
480 enum
481 {
482 	GIT_MERGE_ANALYSIS_NONE = .git_merge_analysis_t.GIT_MERGE_ANALYSIS_NONE,
483 	GIT_MERGE_ANALYSIS_NORMAL = .git_merge_analysis_t.GIT_MERGE_ANALYSIS_NORMAL,
484 	GIT_MERGE_ANALYSIS_UP_TO_DATE = .git_merge_analysis_t.GIT_MERGE_ANALYSIS_UP_TO_DATE,
485 	GIT_MERGE_ANALYSIS_FASTFORWARD = .git_merge_analysis_t.GIT_MERGE_ANALYSIS_FASTFORWARD,
486 	GIT_MERGE_ANALYSIS_UNBORN = .git_merge_analysis_t.GIT_MERGE_ANALYSIS_UNBORN,
487 }
488 
489 /**
490  * The user's stated preference for merges.
491  */
492 enum git_merge_preference_t
493 {
494 	/**
495 	 * No configuration was found that suggests a preferred behavior for
496 	 * merge.
497 	 */
498 	GIT_MERGE_PREFERENCE_NONE = 0,
499 
500 	/**
501 	 * There is a `merge.ff=false` configuration setting, suggesting that
502 	 * the user does not want to allow a fast-forward merge.
503 	 */
504 	GIT_MERGE_PREFERENCE_NO_FASTFORWARD = 1 << 0,
505 
506 	/**
507 	 * There is a `merge.ff=only` configuration setting, suggesting that
508 	 * the user only wants fast-forward merges.
509 	 */
510 	GIT_MERGE_PREFERENCE_FASTFORWARD_ONLY = 1 << 1,
511 }
512 
513 //Declaration name in C language
514 enum
515 {
516 	GIT_MERGE_PREFERENCE_NONE = .git_merge_preference_t.GIT_MERGE_PREFERENCE_NONE,
517 	GIT_MERGE_PREFERENCE_NO_FASTFORWARD = .git_merge_preference_t.GIT_MERGE_PREFERENCE_NO_FASTFORWARD,
518 	GIT_MERGE_PREFERENCE_FASTFORWARD_ONLY = .git_merge_preference_t.GIT_MERGE_PREFERENCE_FASTFORWARD_ONLY,
519 }
520 
521 /**
522  * Analyzes the given branch(es) and determines the opportunities for
523  * merging them into the HEAD of the repository.
524  *
525  * Params:
526  *      analysis_out = analysis enumeration that the result is written into
527  *      repo = the repository to merge
528  *      their_heads = the heads to merge into
529  *      their_heads_len = the number of heads to merge
530  *
531  * Returns: 0 on success or error code
532  */
533 //GIT_EXTERN
534 int git_merge_analysis(.git_merge_analysis_t* analysis_out, .git_merge_preference_t* preference_out, libgit2_d.types.git_repository* repo, const (libgit2_d.types.git_annotated_commit)** their_heads, size_t their_heads_len);
535 
536 /**
537  * Analyzes the given branch(es) and determines the opportunities for
538  * merging them into a reference.
539  *
540  * Params:
541  *      analysis_out = analysis enumeration that the result is written into
542  *      repo = the repository to merge
543  *      our_ref = the reference to perform the analysis from
544  *      their_heads = the heads to merge into
545  *      their_heads_len = the number of heads to merge
546  *
547  * Returns: 0 on success or error code
548  */
549 //GIT_EXTERN
550 int git_merge_analysis_for_ref(.git_merge_analysis_t* analysis_out, .git_merge_preference_t* preference_out, libgit2_d.types.git_repository* repo, libgit2_d.types.git_reference* our_ref, const (libgit2_d.types.git_annotated_commit)** their_heads, size_t their_heads_len);
551 
552 /**
553  * Find a merge base between two commits
554  *
555  * Params:
556  *      out_ = the OID of a merge base between 'one' and 'two'
557  *      repo = the repository where the commits exist
558  *      one = one of the commits
559  *      two = the other commit
560  *
561  * Returns: 0 on success, git_error_code.GIT_ENOTFOUND if not found or error code
562  */
563 //GIT_EXTERN
564 int git_merge_base(libgit2_d.oid.git_oid* out_, libgit2_d.types.git_repository* repo, const (libgit2_d.oid.git_oid)* one, const (libgit2_d.oid.git_oid)* two);
565 
566 /**
567  * Find merge bases between two commits
568  *
569  * Params:
570  *      out_ = array in which to store the resulting ids
571  *      repo = the repository where the commits exist
572  *      one = one of the commits
573  *      two = the other commit
574  *
575  * Returns: 0 on success, git_error_code.GIT_ENOTFOUND if not found or error code
576  */
577 //GIT_EXTERN
578 int git_merge_bases(libgit2_d.oidarray.git_oidarray* out_, libgit2_d.types.git_repository* repo, const (libgit2_d.oid.git_oid)* one, const (libgit2_d.oid.git_oid)* two);
579 
580 /**
581  * Find a merge base given a list of commits
582  *
583  * Params:
584  *      out_ = the OID of a merge base considering all the commits
585  *      repo = the repository where the commits exist
586  *      length = The number of commits in the provided `input_array`
587  *      input_array = oids of the commits
588  *
589  * Returns: Zero on success; git_error_code.GIT_ENOTFOUND or -1 on failure.
590  */
591 //GIT_EXTERN
592 int git_merge_base_many(libgit2_d.oid.git_oid* out_, libgit2_d.types.git_repository* repo, size_t length, const libgit2_d.oid.git_oid[] input_array);
593 
594 /**
595  * Find all merge bases given a list of commits
596  *
597  * Params:
598  *      out_ = array in which to store the resulting ids
599  *      repo = the repository where the commits exist
600  *      length = The number of commits in the provided `input_array`
601  *      input_array = oids of the commits
602  *
603  * Returns: Zero on success; git_error_code.GIT_ENOTFOUND or -1 on failure.
604  */
605 //GIT_EXTERN
606 int git_merge_bases_many(libgit2_d.oidarray.git_oidarray* out_, libgit2_d.types.git_repository* repo, size_t length, const libgit2_d.oid.git_oid[] input_array);
607 
608 /**
609  * Find a merge base in preparation for an octopus merge
610  *
611  * Params:
612  *      out_ = the OID of a merge base considering all the commits
613  *      repo = the repository where the commits exist
614  *      length = The number of commits in the provided `input_array`
615  *      input_array = oids of the commits
616  *
617  * Returns: Zero on success; git_error_code.GIT_ENOTFOUND or -1 on failure.
618  */
619 //GIT_EXTERN
620 int git_merge_base_octopus(libgit2_d.oid.git_oid* out_, libgit2_d.types.git_repository* repo, size_t length, const libgit2_d.oid.git_oid[] input_array);
621 
622 /**
623  * Merge two files as they exist in the in-memory data structures, using
624  * the given common ancestor as the baseline, producing a
625  * `git_merge_file_result` that reflects the merge result.  The
626  * `git_merge_file_result` must be freed with `git_merge_file_result_free`.
627  *
628  * Note that this function does not reference a repository and any
629  * configuration must be passed as `git_merge_file_options`.
630  *
631  * Params:
632  *      out_ = The git_merge_file_result to be filled in
633  *      ancestor = The contents of the ancestor file
634  *      ours = The contents of the file in "our" side
635  *      theirs = The contents of the file in "their" side
636  *      opts = The merge file options or `null` for defaults
637  *
638  * Returns: 0 on success or error code
639  */
640 //GIT_EXTERN
641 int git_merge_file(.git_merge_file_result* out_, const (.git_merge_file_input)* ancestor, const (.git_merge_file_input)* ours, const (.git_merge_file_input)* theirs, const (.git_merge_file_options)* opts);
642 
643 /**
644  * Merge two files as they exist in the index, using the given common
645  * ancestor as the baseline, producing a `git_merge_file_result` that
646  * reflects the merge result.  The `git_merge_file_result` must be freed with
647  * `git_merge_file_result_free`.
648  *
649  * Params:
650  *      out_ = The git_merge_file_result to be filled in
651  *      repo = The repository
652  *      ancestor = The index entry for the ancestor file (stage level 1)
653  *      ours = The index entry for our file (stage level 2)
654  *      theirs = The index entry for their file (stage level 3)
655  *      opts = The merge file options or null
656  *
657  * Returns: 0 on success or error code
658  */
659 //GIT_EXTERN
660 int git_merge_file_from_index(.git_merge_file_result* out_, libgit2_d.types.git_repository* repo, const (libgit2_d.index.git_index_entry)* ancestor, const (libgit2_d.index.git_index_entry)* ours, const (libgit2_d.index.git_index_entry)* theirs, const (.git_merge_file_options)* opts);
661 
662 /**
663  * Frees a `git_merge_file_result`.
664  *
665  * Params:
666  *      result = The result to free or `null`
667  */
668 //GIT_EXTERN
669 void git_merge_file_result_free(.git_merge_file_result* result);
670 
671 /**
672  * Merge two trees, producing a `git_index` that reflects the result of
673  * the merge.  The index may be written as-is to the working directory
674  * or checked out.  If the index is to be converted to a tree, the caller
675  * should resolve any conflicts that arose as part of the merge.
676  *
677  * The returned index must be freed explicitly with `git_index_free`.
678  *
679  * Params:
680  *      out_ = pointer to store the index result in
681  *      repo = repository that contains the given trees
682  *      ancestor_tree = the common ancestor between the trees (or null if none)
683  *      our_tree = the tree that reflects the destination tree
684  *      their_tree = the tree to merge in to `our_tree`
685  *      opts = the merge tree options (or null for defaults)
686  *
687  * Returns: 0 on success or error code
688  */
689 //GIT_EXTERN
690 int git_merge_trees(libgit2_d.types.git_index** out_, libgit2_d.types.git_repository* repo, const (libgit2_d.types.git_tree)* ancestor_tree, const (libgit2_d.types.git_tree)* our_tree, const (libgit2_d.types.git_tree)* their_tree, const (.git_merge_options)* opts);
691 
692 /**
693  * Merge two commits, producing a `git_index` that reflects the result of
694  * the merge.  The index may be written as-is to the working directory
695  * or checked out.  If the index is to be converted to a tree, the caller
696  * should resolve any conflicts that arose as part of the merge.
697  *
698  * The returned index must be freed explicitly with `git_index_free`.
699  *
700  * Params:
701  *      out_ = pointer to store the index result in
702  *      repo = repository that contains the given trees
703  *      our_commit = the commit that reflects the destination tree
704  *      their_commit = the commit to merge in to `our_commit`
705  *      opts = the merge tree options (or null for defaults)
706  *
707  * Returns: 0 on success or error code
708  */
709 //GIT_EXTERN
710 int git_merge_commits(libgit2_d.types.git_index** out_, libgit2_d.types.git_repository* repo, const (libgit2_d.types.git_commit)* our_commit, const (libgit2_d.types.git_commit)* their_commit, const (.git_merge_options)* opts);
711 
712 /**
713  * Merges the given commit(s) into HEAD, writing the results into the working
714  * directory.  Any changes are staged for commit and any conflicts are written
715  * to the index.  Callers should inspect the repository's index after this
716  * completes, resolve any conflicts and prepare a commit.
717  *
718  * For compatibility with git, the repository is put into a merging
719  * state. Once the commit is done (or if the uses wishes to abort),
720  * you should clear this state by calling
721  * `git_repository_state_cleanup()`.
722  *
723  * Params:
724  *      repo = the repository to merge
725  *      their_heads = the heads to merge into
726  *      their_heads_len = the number of heads to merge
727  *      merge_opts = merge options
728  *      checkout_opts = checkout options
729  *
730  * Returns: 0 on success or error code
731  */
732 //GIT_EXTERN
733 int git_merge(libgit2_d.types.git_repository* repo, const (libgit2_d.types.git_annotated_commit)** their_heads, size_t their_heads_len, const (.git_merge_options)* merge_opts, const (libgit2_d.checkout.git_checkout_options)* checkout_opts);
734 
735 /** @} */