Documentation / technical / trivial-merge.txton commit [PATCH] Documentation: Update all files to use the new gitlink: macro (a7154e9)
   1Trivial merge rules
   2===================
   3
   4This document describes the outcomes of the trivial merge logic in read-tree.
   5
   6One-way merge
   7-------------
   8
   9This replaces the index with a different tree, keeping the stat info
  10for entries that don't change, and allowing -u to make the minimum
  11required changes to the working tree to have it match.
  12
  13   index   tree    result
  14   -----------------------
  15   *       (empty) (empty)
  16   (empty) tree    tree
  17   index+  tree    tree
  18   index+  index   index+
  19
  20Two-way merge
  21-------------
  22
  23
  24
  25Three-way merge
  26---------------
  27
  28It is permitted for the index to lack an entry; this does not prevent
  29any case from applying.
  30
  31If the index exists, it is an error for it not to match either the
  32head or (if the merge is trivial) the result.
  33
  34If multiple cases apply, the one used is listed first.
  35
  36A result of "no merge" means that index is left in stage 0, ancest in
  37stage 1, head in stage 2, and remote in stage 3 (if any of these are
  38empty, no entry is left for that stage). Otherwise, the given entry is
  39left in stage 0, and there are no other entries.
  40
  41A result of "no merge" is an error if the index is not empty and not
  42up-to-date.
  43
  44*empty* means that the tree must not have a directory-file conflict
  45 with the entry.
  46
  47For multiple ancestors or remotes, a '+' means that this case applies
  48even if only one ancestor or remote fits; normally, all of the
  49ancestors or remotes must be the same.
  50
  51case  ancest    head    remote    result
  52----------------------------------------
  531     (empty)+  (empty) (empty)   (empty)
  542ALT  (empty)+  *empty* remote    remote
  552ALT  (empty)+  *empty* remote    remote
  562     (empty)^  (empty) remote    no merge
  573ALT  (empty)+  head    *empty*   head
  583     (empty)^  head    (empty)   no merge
  594     (empty)^  head    remote    no merge
  605ALT  *         head    head      head
  616     ancest^   (empty) (empty)   no merge
  628ALT  ancest    (empty) ancest    (empty)
  637     ancest+   (empty) remote    no merge
  649     ancest+   head    (empty)   no merge
  6510ALT ancest    ancest  (empty)   (empty)
  6611    ancest+   head    remote    no merge
  6716    anc1/anc2 anc1    anc2      no merge
  6813    ancest+   head    ancest    head
  6914    ancest+   ancest  remote    remote
  7014ALT ancest+   ancest  remote    remote
  71
  72Only #2ALT and #3ALT use *empty*, because these are the only cases
  73where there can be conflicts that didn't exist before. Note that we
  74allow directory-file conflicts between things in different stages
  75after the trivial merge.
  76
  77A possible alternative for #6 is (empty), which would make it like
  78#1. This is not used, due to the likelihood that it arises due to
  79moving the file to multiple different locations or moving and deleting
  80it in different branches.
  81
  82Case #1 is included for completeness, and also in case we decide to
  83put on '+' markings; any path that is never mentioned at all isn't
  84handled.
  85
  86Note that #16 is when both #13 and #14 apply; in this case, we refuse
  87the trivial merge, because we can't tell from this data which is
  88right. This is a case of a reverted patch (in some direction, maybe
  89multiple times), and the right answer depends on looking at crossings
  90of history or common ancestors of the ancestors.
  91
  92The status as of Sep 5 is that multiple remotes are not supported