]> git.ipfire.org Git - thirdparty/git.git/commit - rerere.c
rerere: teach rerere to handle nested conflicts
authorThomas Gummerer <t.gummerer@gmail.com>
Sun, 5 Aug 2018 17:20:36 +0000 (18:20 +0100)
committerJunio C Hamano <gitster@pobox.com>
Mon, 6 Aug 2018 20:22:35 +0000 (13:22 -0700)
commit4af32207bc106412a456791037fc4a402101fbb4
treeac14ac661e9e350f003e6ed6c981cb918b12c0c8
parent5ebbdad3447ccaaf5af18a5f4f8f5065bd9fff3d
rerere: teach rerere to handle nested conflicts

Currently rerere can't handle nested conflicts and will error out when
it encounters such conflicts.  Do that by recursively calling the
'handle_conflict' function to normalize the conflict.

Note that a conflict like this would only be produced if a user
commits a file with conflict markers, and gets a conflict including
that in a susbsequent operation.

The conflict ID calculation here deserves some explanation:

As we are using the same handle_conflict function, the nested conflict
is normalized the same way as for non-nested conflicts, which means
the ancestor in the diff3 case is stripped out, and the parts of the
conflict are ordered alphabetically.

The conflict ID is however is only calculated in the top level
handle_conflict call, so it will include the markers that 'rerere'
adds to the output.  e.g. say there's the following conflict:

    <<<<<<< HEAD
    1
    =======
    <<<<<<< HEAD
    3
    =======
    2
    >>>>>>> branch-2
    >>>>>>> branch-3~

it would be recorde as follows in the preimage:

    <<<<<<<
    1
    =======
    <<<<<<<
    2
    =======
    3
    >>>>>>>
    >>>>>>>

and the conflict ID would be calculated as

    sha1(1<NUL><<<<<<<
    2
    =======
    3
    >>>>>>><NUL>)

Stripping out vs. leaving the conflict markers in place in the inner
conflict should have no practical impact, but it simplifies the
implementation.

Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/technical/rerere.txt
rerere.c
t/t4200-rerere.sh