git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: git@vger.kernel.org
Cc: Stefan Monnier <monnier@iro.umontreal.ca>
Subject: [PATCH 04/10] checkout --conflict=diff3: add a label for ancestor
Date: Mon, 15 Mar 2010 02:55:09 -0500	[thread overview]
Message-ID: <20100315075509.GD8824@progeny.tock> (raw)
In-Reply-To: <20100315074748.GA28827@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 can be very 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 “||||||| original”.

git rerere will not have trouble parsing this output, since instead of
looking for a newline, it looks for whitespace after the |||||||
marker.  No other code in git tries to parse conflict hunks.

Reported-by: Stefan Monnier <monnier@iro.umontreal.ca>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Since “original” a good name for the common ancestor?  I also
considered “base” and “ancestor”; the latter is too jargon-y for my
taste, but “base” seems all right.

 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..c60c3e0 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, "original",
 			  &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..ebfa5ca 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 "||||||| original"
 		echo original
 		echo "======="
 		echo theirside
@@ -525,7 +525,7 @@ test_expect_success 'checkout --conflict=diff3' '
 	(
 		echo "<<<<<<< ours"
 		echo ourside
-		echo "|||||||"
+		echo "||||||| original"
 		echo original
 		echo "======="
 		echo theirside
-- 
1.7.0

  parent reply	other threads:[~2010-03-15  7:55 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20100305215253.364.63583.reportbug@localhost>
2010-03-05 22:19 ` git-core: conflictstyle=diff3 doesn't actually use diff3 compatible format Jonathan Nieder
2010-03-05 22:31   ` Junio C Hamano
2010-03-06 12:57     ` Bert Wesarg
2010-03-06 19:03       ` Junio C Hamano
2010-03-08  4:54     ` Jonathan Nieder
2010-03-15  7:47   ` [PATCH/RFC 0/10] Add label for common ancestor to conflictstyle=diff3 Jonathan Nieder
2010-03-15  7:49     ` [PATCH 01/10] xdl_merge(): add optional ancestor label to diff3-style output Jonathan Nieder
2010-03-15  8:10       ` Junio C Hamano
2010-03-15  8:35         ` Jonathan Nieder
2010-03-15  8:37           ` Junio C Hamano
2010-03-15  7:51     ` [PATCH 02/10] merge-file --diff3: add a label for ancestor Jonathan Nieder
2010-03-15  7:52     ` [PATCH 03/10] ll_merge(): add ancestor label parameter for diff3-style output Jonathan Nieder
2010-03-15  7:55     ` Jonathan Nieder [this message]
2010-03-15  8:20       ` [PATCH 04/10] checkout --conflict=diff3: add a label for ancestor Junio C Hamano
2010-03-15  8:32         ` Jonathan Nieder
2010-03-15  7:56     ` [PATCH 05/10] merge_file(): add comment explaining behavior wrt conflict style Jonathan Nieder
2010-03-15  8:00     ` [PATCH 06/10] merge_trees(): add ancestor label parameter for diff3-style output Jonathan Nieder
2010-03-15  8:00     ` [PATCH 07/10] tests: document format of conflicts from checkout -m Jonathan Nieder
2010-03-15  8:01     ` [PATCH 08/10] checkout -m --conflict=diff3: add a label for ancestor Jonathan Nieder
2010-03-15  8:05     ` [PATCH 09/10] cherry-pick: " Jonathan Nieder
2010-03-15  8:07     ` [PATCH 10/10] merge-recursive: " Jonathan Nieder
2010-03-15  8:29       ` Junio C Hamano
2010-03-15 13:18       ` Stefan Monnier

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100315075509.GD8824@progeny.tock \
    --to=jrnieder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=monnier@iro.umontreal.ca \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).