Skip to content

Commit c415162

Browse files
jrngitster
authored andcommitted
checkout -m --conflict=diff3: add a label for ancestor
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 <[email protected]> Signed-off-by: Jonathan Nieder <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 4c5868f commit c415162

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

builtin/checkout.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,7 @@ static int merge_working_tree(struct checkout_opts *opts,
439439
ret = reset_tree(new->commit->tree, opts, 1);
440440
if (ret)
441441
return ret;
442+
o.ancestor = old->name;
442443
o.branch1 = new->name;
443444
o.branch2 = "local";
444445
merge_trees(&o, new->commit->tree, work,

t/t7201-co.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ test_expect_success 'checkout --merge --conflict=diff3 <branch>' '
209209
a
210210
c
211211
e
212-
|||||||
212+
||||||| master
213213
a
214214
b
215215
c

0 commit comments

Comments
 (0)