Skip to content

Commit f0531a2

Browse files
jrngitster
authored andcommitted
checkout --conflict=diff3: add a label for ancestor
git checkout --conflict=diff3 can be used to present conflicts hunks including text from the common ancestor: <<<<<<< ours ourside ||||||| original ======= theirside >>>>>>> theirs The added information is helpful for resolving a merge by hand, and merge tools can usually understand it without trouble because it looks like output from ‘diff3 -m’. diff3 includes a label for the merge base on the ||||||| line, and it seems some tools (for example, Emacs 22’s smerge-mode) cannot parse conflict hunks without such a label. Humans could use help in interpreting the output, too. So change the marker for the start of the text from the common ancestor to include the label “base”. git rerere’s conflict identifiers are not affected: to parse conflict hunks, rerere looks for whitespace after the ||||||| marker rather than a newline, and to compute preimage ids, rerere has its own code for creating 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>
1 parent f01de62 commit f0531a2

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

builtin/checkout.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ static int checkout_merged(int pos, struct checkout *state)
149149
read_mmblob(&ours, active_cache[pos+1]->sha1);
150150
read_mmblob(&theirs, active_cache[pos+2]->sha1);
151151

152-
status = ll_merge(&result_buf, path, &ancestor, NULL,
152+
status = ll_merge(&result_buf, path, &ancestor, "base",
153153
&ours, "ours", &theirs, "theirs", 0);
154154
free(ancestor.ptr);
155155
free(ours.ptr);

t/t7201-co.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ test_expect_success 'checkout with --merge, in diff3 -m style' '
538538
(
539539
echo "<<<<<<< ours"
540540
echo ourside
541-
echo "|||||||"
541+
echo "||||||| base"
542542
echo original
543543
echo "======="
544544
echo theirside
@@ -582,7 +582,7 @@ test_expect_success 'checkout --conflict=diff3' '
582582
(
583583
echo "<<<<<<< ours"
584584
echo ourside
585-
echo "|||||||"
585+
echo "||||||| base"
586586
echo original
587587
echo "======="
588588
echo theirside

0 commit comments

Comments
 (0)