From: Elijah Newren <newren@gmail.com>
To: Felipe Contreras <felipe.contreras@gmail.com>
Cc: "Sergey Organov" <sorganov@gmail.com>,
"Junio C Hamano" <gitster@pobox.com>,
"Johannes Sixt" <j6t@kdbg.org>, "Jeff King" <peff@peff.net>,
"David Aguilar" <davvid@gmail.com>,
"Bagas Sanjaya" <bagasdotme@gmail.com>,
"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
"Denton Liu" <liu.denton@gmail.com>,
"Git Mailing List" <git@vger.kernel.org>,
"Elijah Newren" <newren@gmail.com>
Subject: Re: [PATCH 7/7] xdiff: make diff3 the default conflictStyle
Date: Fri, 11 Jun 2021 12:02:35 -0700 [thread overview]
Message-ID: <20210611190235.1970106-1-newren@gmail.com> (raw)
In-Reply-To: <60c3a41bd25e3_8d0f2089e@natae.notmuch>
On Fri, Jun 11, 2021 at 10:57 AM Felipe Contreras <felipe.contreras@gmail.com> wrote:
> Elijah Newren wrote:
> > On Fri, Jun 11, 2021 at 8:32 AM Felipe Contreras <felipe.contreras@gmail.com>
> > wrote:
...
> > The alternative to the above two options was the
> > make-a-virtual-merge-base-by-merging-merge-bases strategy. It apparently
> > was very successful.
>
> OK. That makes sense.
>
> > But it does mean that merge bases can have conflict markers in them.
>
> But why? And even if they do, why do they have to be diff3 conflict
> markers?
This could be changed; I suspect it just was a natural consequence of how
the code was built. (Recursive means there's not a separate code-path for
merging the merge-bases, so they get the same merge style by default.)
> This would be more human-friendly:
>
> <<<<<<< HEAD
> D
> ||||||| merged common ancestors
> <<<<<<<<< Temporary merge branch 1
> B
> =========
> A
> >>>>>>>>> Temporary merge branch 2
> =======
> C
> >>>>>>> C
I suspect that would be as easy as this (not compiled or tested):
diff --git a/ll-merge.c b/ll-merge.c
index 095a4d820e..bdd129cbd6 100644
--- a/ll-merge.c
+++ b/ll-merge.c
@@ -131,7 +131,7 @@ static int ll_xdl_merge(const struct ll_merge_driver *drv_unused,
xmp.level = XDL_MERGE_ZEALOUS;
xmp.favor = opts->variant;
xmp.xpp.flags = opts->xdl_opts;
- if (git_xmerge_style >= 0)
+ if (git_xmerge_style >= 0 && !opts->virtual_ancestor)
xmp.style = git_xmerge_style;
if (marker_size > 0)
xmp.marker_size = marker_size;
> Or just put a stub conflict marker:
>
> <<<<<<< HEAD
> D
> ||||||| merged common ancestors
> <<<<<<<<< Temporary merge >>>>>>>>>
> =======
> C
> >>>>>>> C
I don't know what would be involved to do this one; I think it wouldn't
be too hard, but I don't think we'd want to pursue this option.
> Or just use the base of the virtual merge:
>
> <<<<<<< HEAD
> D
> ||||||| merged common ancestors
> 1
> =======
> C
> >>>>>>> C
I think that implementing this choice would look like this (again, not
compiled or tested and I'm not familiar with xdiff so take it with a
big grain of salt):
diff --git a/ll-merge.c b/ll-merge.c
index 095a4d820e..dbc7f76951 100644
--- a/ll-merge.c
+++ b/ll-merge.c
@@ -130,6 +130,8 @@ static int ll_xdl_merge(const struct ll_merge_driver *drv_unused,
memset(&xmp, 0, sizeof(xmp));
xmp.level = XDL_MERGE_ZEALOUS;
xmp.favor = opts->variant;
+ if (git_xmerge_style >= 0 && opts->virtual_ancestor)
+ xmp.favor = XDL_MERGE_FAVOR_BASE;
xmp.xpp.flags = opts->xdl_opts;
if (git_xmerge_style >= 0)
xmp.style = git_xmerge_style;
diff --git a/xdiff/xdiff.h b/xdiff/xdiff.h
index 8629ae287c..b8d1a536c2 100644
--- a/xdiff/xdiff.h
+++ b/xdiff/xdiff.h
@@ -62,6 +62,7 @@ extern "C" {
#define XDL_MERGE_FAVOR_OURS 1
#define XDL_MERGE_FAVOR_THEIRS 2
#define XDL_MERGE_FAVOR_UNION 3
+#define XDL_MERGE_FAVOR_BASE 4
/* merge output styles */
#define XDL_MERGE_DIFF3 1
diff --git a/xdiff/xmerge.c b/xdiff/xmerge.c
index 95871a0b6e..a8dc42595a 100644
--- a/xdiff/xmerge.c
+++ b/xdiff/xmerge.c
@@ -313,6 +313,9 @@ static int xdl_fill_merge_buffer(xdfenv_t *xe1, const char *name1,
if (m->mode & 2)
size += xdl_recs_copy(xe2, m->i2, m->chg2, 0, 0,
dest ? dest + size : NULL);
+ } else if (m->mode == 4) {
+ size += xdl_orig_copy(xe1, m->i0, m->chg0, needs_cr, 0,
+ dest ? dest + size : NULL);
} else
continue;
i = m->i1 + m->chg1;
> We don't have to use diff3 all the way.
Right, thus my mention in the other email to consider adding a
XDL_MERGE_FAVOR_BASE -- which you then also mention here in your third
option, and which I've now given at least a partial patch for. Not
sure if it's a crazy idea or a great idea, since I don't do very many
criss-cross merges myself.
Hope that helps,
Elijah
next prev parent reply other threads:[~2021-06-11 19:04 UTC|newest]
Thread overview: 69+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-06-09 19:28 [PATCH 0/7] Make diff3 the default conflict style Felipe Contreras
2021-06-09 19:28 ` [PATCH 1/7] test: add merge style config test Felipe Contreras
2021-06-09 19:42 ` Eric Sunshine
2021-06-09 20:29 ` Felipe Contreras
2021-06-10 9:18 ` Phillip Wood
2021-06-10 13:26 ` Felipe Contreras
2021-06-10 14:54 ` Phillip Wood
2021-06-10 16:34 ` Felipe Contreras
2021-06-10 14:58 ` Phillip Wood
2021-06-10 16:47 ` Felipe Contreras
2021-06-11 9:19 ` Phillip Wood
2021-06-11 14:39 ` Felipe Contreras
2021-06-09 19:28 ` [PATCH 2/7] merge-tree: fix merge.conflictstyle handling Felipe Contreras
2021-06-09 19:28 ` [PATCH 3/7] notes: " Felipe Contreras
2021-06-09 19:28 ` [PATCH 4/7] checkout: " Felipe Contreras
2021-06-10 9:32 ` Phillip Wood
2021-06-10 14:11 ` Felipe Contreras
2021-06-10 14:50 ` Phillip Wood
2021-06-10 16:32 ` Felipe Contreras
2021-06-11 9:18 ` Phillip Wood
2021-06-11 14:34 ` Felipe Contreras
2021-06-11 9:18 ` Phillip Wood
2021-06-09 19:28 ` [PATCH 5/7] xdiff: rename XDL_MERGE_STYLE_DIFF3 Felipe Contreras
2021-06-10 9:21 ` Phillip Wood
2021-06-10 13:33 ` Felipe Contreras
2021-06-11 3:17 ` Junio C Hamano
2021-06-11 13:42 ` Felipe Contreras
2021-06-09 19:28 ` [PATCH 6/7] xdiff: simplify style assignments Felipe Contreras
2021-06-10 9:26 ` Phillip Wood
2021-06-10 13:50 ` Felipe Contreras
2021-06-09 19:28 ` [PATCH 7/7] xdiff: make diff3 the default conflictStyle Felipe Contreras
2021-06-10 6:41 ` Johannes Sixt
2021-06-10 7:53 ` Đoàn Trần Công Danh
2021-06-10 13:18 ` Felipe Contreras
2021-06-10 13:18 ` Felipe Contreras
2021-06-10 13:49 ` Jeff King
2021-06-10 16:00 ` Felipe Contreras
2021-06-10 16:31 ` Jeff King
2021-06-11 1:20 ` Junio C Hamano
2021-06-11 6:23 ` Johannes Sixt
2021-06-11 6:43 ` Junio C Hamano
2021-06-11 7:02 ` Johannes Sixt
2021-06-11 7:14 ` Junio C Hamano
2021-06-11 11:51 ` Sergey Organov
2021-06-11 15:32 ` Felipe Contreras
2021-06-11 15:52 ` Sergey Organov
2021-06-11 16:36 ` Felipe Contreras
[not found] ` <CABPp-BHRQSF2_aYTBfpfnW4Bh3Hz7vLFj_QNGj8R4WeCS6_utw@mail.gmail.com>
2021-06-11 17:57 ` Felipe Contreras
2021-06-11 19:02 ` Elijah Newren [this message]
2021-06-11 21:05 ` Felipe Contreras
2021-06-11 21:40 ` Elijah Newren
2021-06-13 14:34 ` Felipe Contreras
2021-06-11 16:41 ` Johannes Sixt
2021-06-11 17:21 ` Felipe Contreras
2021-06-11 17:40 ` Sergey Organov
2021-06-11 18:10 ` Felipe Contreras
2021-06-11 18:22 ` Sergey Organov
2021-06-11 14:28 ` Felipe Contreras
2021-06-11 14:25 ` Felipe Contreras
2021-06-11 16:53 ` Johannes Sixt
[not found] ` <CABPp-BH0aRiSUw03nSK6jHRNQ+zcpUzr6WjeJ5GpdUCqCKxbag@mail.gmail.com>
2021-06-11 17:32 ` Felipe Contreras
2021-06-11 17:57 ` Elijah Newren
2021-06-11 18:28 ` Felipe Contreras
2021-06-11 14:20 ` Felipe Contreras
2021-06-11 14:09 ` Felipe Contreras
2021-06-10 9:40 ` Phillip Wood
2021-06-10 14:19 ` Felipe Contreras
2021-06-17 17:40 ` [PATCH 0/7] Make diff3 the default conflict style Phillip Wood
2021-06-17 18:24 ` Felipe Contreras
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
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210611190235.1970106-1-newren@gmail.com \
--to=newren@gmail.com \
--cc=avarab@gmail.com \
--cc=bagasdotme@gmail.com \
--cc=davvid@gmail.com \
--cc=felipe.contreras@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=j6t@kdbg.org \
--cc=liu.denton@gmail.com \
--cc=peff@peff.net \
--cc=sorganov@gmail.com \
/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.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).