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