[PATCH 05/16] checkout --conflict=diff3: add a label for ancestor
- From
Jonathan Nieder <jrnieder@gmail.com>
- Date
- Mar 17, 2010, 12:04 UTC
- Message-ID
- <20100317120459.GE25641@progeny.tock>
- In-Reply-To
- <20100317113655.GA25470@progeny.tock>
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’.
Unfortunately, not all can: diff3 includes a label for the merge base on the ||||||| line and it seems some tools cannot parse conflict hunks without such a label. Humans could use help in interpreting the output, too. So mark the start of the text from the common ancestor with 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> --- Label changed. Thanks for the feedback.
builtin/checkout.c | 2 +- t/t7201-co.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/builtin/checkout.c b/builtin/checkout.c index d67f809..d652b4c 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -149,7 +149,7 @@ static int checkout_merged(int pos, struct checkout *state) read_mmblob(&ours, active_cache[pos+1]->sha1); read_mmblob(&theirs, active_cache[pos+2]->sha1); - status = ll_merge(&result_buf, path, &ancestor, NULL, + status = ll_merge(&result_buf, path, &ancestor, "base", &ours, "ours", &theirs, "theirs", 0); free(ancestor.ptr); free(ours.ptr); diff --git a/t/t7201-co.sh b/t/t7201-co.sh index d20ed61..981ae8f 100755 --- a/t/t7201-co.sh +++ b/t/t7201-co.sh @@ -481,7 +481,7 @@ test_expect_success 'checkout with --merge, in diff3 -m style' ' ( echo "<<<<<<< ours" echo ourside - echo "|||||||" + echo "||||||| base" echo original echo "=======" echo theirside @@ -525,7 +525,7 @@ test_expect_success 'checkout --conflict=diff3' ' ( echo "<<<<<<< ours" echo ourside - echo "|||||||" + echo "||||||| base" echo original echo "=======" echo theirside
-- 1.7.0