Skip to content

Commit

Permalink
checkout -m --conflict=diff3: add a label for ancestor
Browse files Browse the repository at this point in the history
git checkout --merge --conflict=diff3 can be used to present conflict
hunks including text from the common ancestor.  The added information
is helpful for resolving a merge by hand, and merge tools tend to
understand it because it is very similar to what ‘diff3 -m’ produces.

Unlike current git, diff3 -m includes a label for the merge base on
the ||||||| line, and unfortunately, some tools cannot parse the
conflict hunks without it.  Humans can benefit from a cue when
learning to interpreting the format, too.  Mark the start of the text
from the old branch with a label based on the branch’s name.

git rerere does not have trouble parsing this output and its preimage
ids are unchanged since it includes its own code for recreating
conflict hunks.  No other code in git tries to parse conflict hunks.

Requested-by: Stefan Monnier <monnier@iro.umontreal.ca>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jonathan Nieder authored and Junio C Hamano committed Mar 21, 2010
1 parent 4c5868f commit c415162
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
1 change: 1 addition & 0 deletions builtin/checkout.c
Original file line number Diff line number Diff line change
Expand Up @@ -439,6 +439,7 @@ static int merge_working_tree(struct checkout_opts *opts,
ret = reset_tree(new->commit->tree, opts, 1);
if (ret)
return ret;
o.ancestor = old->name;
o.branch1 = new->name;
o.branch2 = "local";
merge_trees(&o, new->commit->tree, work,
Expand Down
2 changes: 1 addition & 1 deletion t/t7201-co.sh
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ test_expect_success 'checkout --merge --conflict=diff3 <branch>' '
a
c
e
|||||||
||||||| master
a
b
c
Expand Down

0 comments on commit c415162

Please sign in to comment.