[PATCH 08/10] checkout -m --conflict=diff3: add a label for ancestor
- From
Jonathan Nieder <jrnieder@gmail.com>
- Date
- Mar 15, 2010, 08:01 UTC
- Message-ID
- <20100315080134.GH8824@progeny.tock>
- In-Reply-To
- <20100315074748.GA28827@progeny.tock>
git checkout --merge --conflict=diff3 can be used to present conflicts hunks including text from the common ancestor.
The added information can be very helpful for resolving a merge by hand, and many merge tools can usually grok it because it is very similar to the output from ‘diff3 -m’.
Unfortunately, some tools reportedly cannot parse the conflict hunks because of a small difference from diff3: diff3 -m includes a label for the merge base on the ||||||| line. Humans can benefit from a cue when learning to interpreting the format, too. So mark the start of the text from the old branch with a label based on the branch’s name.
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> --- builtin/checkout.c | 1 + t/t7201-co.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/builtin/checkout.c b/builtin/checkout.c index c60c3e0..ebc5891 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -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, diff --git a/t/t7201-co.sh b/t/t7201-co.sh index 970a460..ae14b19 100755 --- a/t/t7201-co.sh +++ b/t/t7201-co.sh @@ -209,7 +209,7 @@ test_expect_success 'checkout --merge --conflict=diff3 <branch>' ' a c e - ||||||| + ||||||| master a b c
-- 1.7.0