Skip to content

mergeTrees

Merge two trees, producing an index that reflects the result of the merge. The index may be written as-is to the working directory or checked out. If the index is to be converted to a tree, the caller should resolve any conflicts that arose as part of the merge.

Signature

ts
class Repository {
  mergeTrees(
    ancestorTree: Tree,
    ourTree: Tree,
    theirTree: Tree,
    options?: MergeOptions | undefined | null,
  ): Index;
}

Parameters

  • ancestorTreerequired · Tree

    The common ancestor between.

  • ourTreerequired · Tree
  • theirTreerequired · Tree

    The tree to merge in to ourTree.

  • optionsnull | MergeOptions

    Merge options.

    • diff3Styleboolean

      Create diff3-style file

    • failOnConflictboolean

      If a conflict occurs, exit immediately instead of attempting to continue resolving conflicts

    • filFavorFileFavor

      Specify a side to favor for resolving conflicts

    • findRenamesboolean

      Detect file renames

    • ignoreWhitespaceboolean

      Ignore all whitespace

    • ignoreWhitespaceChangeboolean

      Ignore changes in amount of whitespace

    • ignoreWhitespaceEolboolean

      Ignore whitespace at end of line

    • minimalboolean

      Take extra time to find minimal diff

    • noRecursiveboolean

      If the commits being merged have multiple merge bases, do not build a recursive merge base (by merging the multiple merge bases), instead simply use the first base.

    • patienceboolean

      Use the "patience diff" algorithm

    • recursionLimitnumber

      Maximum number of times to merge common ancestors to build a virtual merge base when faced with criss-cross merges. When this limit is reached, the next ancestor will simply be used instead of attempting to merge it. The default is unlimited.

    • renameThresholdnumber

      Similarity to consider a file renamed (default 50)

    • simplifyAlnumboolean

      Condense non-alphanumeric regions for simplified diff file

    • skipReucboolean

      Do not write the REUC extension on the generated index

    • standardStyleboolean

      Create standard conflicted merge files

    • targetLimitnumber

      Maximum similarity sources to examine for renames (default 200). If the number of rename candidates (add / delete pairs) is greater than this value, inexact rename detection is aborted. This setting overrides the merge.renameLimit configuration value.

Returns

  • Index

    The index result.

Released under the MIT License.