]> git.ipfire.org Git - thirdparty/git.git/commit - merge-recursive.c
merge-recursive: avoid showing conflicts with merge branch before HEAD
authorElijah Newren <newren@gmail.com>
Tue, 16 Oct 2018 20:19:48 +0000 (13:19 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 18 Oct 2018 05:45:39 +0000 (14:45 +0900)
commit4f445453136b8c3575bc4d4c45fc9b7930688a5c
tree3c775134988ef6cdb720fecb6dc39b039d5898d3
parent2b168ef3ffa308537d858b9910170e4d314a8f4a
merge-recursive: avoid showing conflicts with merge branch before HEAD

We want to load unmerged entries from HEAD into the index at stage 2 and
from MERGE_HEAD into stage 3.  Similarly, folks expect merge conflicts
to look like

    <<<<<<<< HEAD
    content from our side
    ========
    content from their side
    >>>>>>>> MERGE_HEAD

not

    <<<<<<<< MERGE_HEAD
    content from their side
    ========
    content from our side
    >>>>>>>> HEAD

The correct order usually comes naturally and for free, but with renames
we often have data in the form {rename_branch, other_branch}, and
working relative to the rename first (e.g. for rename/add) is more
convenient elsewhere in the code.  Address the slight impedance
mismatch by having some functions re-call themselves with flipped
arguments when the branch order is reversed.

Note that setup_rename_conflict_info() has one asymmetry in it, in
setting dst_entry1->processed=0 but not doing similarly for
dst_entry2->processed.  When dealing with rename/rename and similar
conflicts, we do not want the processing to happen twice, so the
desire to only set one of the entries to unprocessed is intentional.
So, while this change modifies which branch's entry will be marked as
unprocessed, that dovetails nicely with putting HEAD first so that we
get the index stage entries and conflict markers in the right order.

Signed-off-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
merge-recursive.c
t/t6036-recursive-corner-cases.sh