All of lore.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Seth House <seth@eseth.com>
Cc: Felipe Contreras <felipe.contreras@gmail.com>,
	Johannes Sixt <j6t@kdbg.org>,
	git@vger.kernel.org, David Aguilar <davvid@gmail.com>
Subject: Re: [RFC/PATCH] mergetool: use resolved conflicts in all the views
Date: Thu, 17 Dec 2020 11:28:25 -0800	[thread overview]
Message-ID: <xmqq5z50z0yu.fsf@gitster.c.googlers.com> (raw)
In-Reply-To: <20201217175037.GA80608@ellen> (Seth House's message of "Thu, 17 Dec 2020 10:50:37 -0700")

Seth House <seth@eseth.com> writes:

> Would you mind switching the autoMerge option to be per-tool rather than
> under the main mergetool config section?
>
> You're right that it will likely not cause any downstream errors; it's
> just a difference in preference. The tools that perform their own
> conflict resolution will likely want it off and most of the other tools
> will likely want it on. I could envision wanting to configure multiple
> mergetools -- some with and some without.

Thanks for a concise summary.

Many people may stick to just a single tool and may find a single
mergetool.autoMerge knob convenient (and it is OK for them if the
new behaviour broke a tool they do not use), but for those who use
more than one, being able to configure them differently would be
valuable.  So I agree that making it a per-tool option would be a
good thing to do.  Extra bonus for "this covers all" fallback default
perhaps like so:

	if test "$(git config --get --bool "mergetool.$merge_tool.automerge" ||
	           git config --get --bool "mergetool.autoMerge" ||
	           echo true)" = true
	then
		... do the new "reduce conflicts" thing ...
	else
		... do the "grab the original" thing ...
	fi

There is another thing that the final version may want to consider.

Would there be a reason for a tool to actively want to refuse the
end-user request to use the new autoMerge behaviour?  A tool that
can merge binary files may want to make sure it gets the original
three blobs that got involved in the conflict, and the above
would allow users to break such a tool.  We could say "don't do
that then" to users, or we can use the same mechanism to set up
diff_cmd() etc. per tool [*1*].  A tool that always wants to use
the autoMerge without letting end-user to opt out can be handled
with the same mechanism, but I think that is less likely.

Also, just for completeness (this is a comment made after seeing v3),
unlike the previous rounds, we do not have to worry about conflict
marker length attribute user may have and rely on the default
marker-size hardcoded at the xdl_merge() layer.  If we wanted to
make it even safer, "git merge-file --diff3" invocation can also
use a hardcoded --marker-size=7 option to protect from changes in
the underlying xdl_merge()'s default.

Unfortunately, it however also means that we can be confused when we
are seeing a conflicted outer merge of a recursive merge.  In such a
case, the virtual ancestor version in stage #1 can have conflict
markers from the inner merge that also conflicted, which uses marker
size a bit longer than what the user gave via the attribute
machinery.  If that "a bit longer" length happens to be the same as
the hardcoded assumption of 7 the sed script in v3 makes, the sed
script would not be able to tell between the existing markers in the
virtual ancestor version and the markers "git merge-file --diff3"
creates.

It is unlikely that the end-user sets conflict marker length to
anything shorter than the default 7, so I think it is OK to punt
this potential problem, and assume we are OK.  The limitation may
need to be documented, though.

> After work today I can go back through the list of mergetools reviewed
> in my post and grab screenshots of each with this option enabled so that
> everyone in this thread can quickly compare the before/after results.

Thanks.


[Footnote]

*1* If we were to go that extra mile for completeness, the result
    would roughly look like the following outline:

 1. git-mergetool--lib.sh::setup_tool() would define a new helper
    function 

	automerge_enabled () {
		true
	}

    to be used as the fallback

 2. a tool that wants to use the original without allowing the user
    to opt into automerge would add

	automerge_enabled () {
		false
	}

    in mergetools/$toolname (where toolname is like 'tkdiff',
    'vimdiff', etc.)

 3. then the "consult mergetool.<tool>.automerge and then
    mergetool.automerge in this order" if statement we saw above
    would first ask the new helper function, i.e.

	if automerge_enabled &&
	   test "$(git config --get --bool "mergetool.$merge_tool.automerge" ||
                   git config --get --bool "mergetool.automerge" ||
	           echo true)" = true
	then
		...


  reply	other threads:[~2020-12-17 19:29 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-16 17:43 [RFC/PATCH] mergetool: use resolved conflicts in all the views Felipe Contreras
2020-12-16 22:24 ` Junio C Hamano
2020-12-16 22:53   ` Seth House
2020-12-17  5:18     ` Junio C Hamano
2020-12-17  5:41     ` Felipe Contreras
2020-12-17  7:35       ` Johannes Sixt
2020-12-17  8:27         ` Felipe Contreras
2020-12-17 19:23           ` Johannes Sixt
2020-12-18  2:30             ` Felipe Contreras
2020-12-17  9:44         ` Seth House
2020-12-17 10:35           ` Felipe Contreras
2020-12-17 17:50             ` Seth House
2020-12-17 19:28               ` Junio C Hamano [this message]
2020-12-18  2:34                 ` Felipe Contreras
     [not found]                   ` <CANiSa6jMXTyfo43bUdC8601BvYKiF67HXo+QaiTh_-8KWyBsLg@mail.gmail.com>
2020-12-21  0:31                     ` Felipe Contreras
2020-12-18  2:05               ` Felipe Contreras
2020-12-18  2:35                 ` Seth House
2020-12-18  2:49                   ` Felipe Contreras
2020-12-18  5:49                     ` Seth House
2020-12-18  9:46                       ` Felipe Contreras
2020-12-19  0:13                         ` Seth House
2020-12-19  0:53                           ` Felipe Contreras
2020-12-19 11:14                           ` Junio C Hamano
2020-12-19 12:08                             ` Felipe Contreras
2020-12-19 18:26                               ` Junio C Hamano
2020-12-19 20:18                                 ` Felipe Contreras
2020-12-21  4:25                             ` Seth House
2020-12-21  5:34                               ` Felipe Contreras
2020-12-21  7:36                                 ` Seth House
2020-12-21 11:17                                   ` Felipe Contreras
2020-12-21 22:15                                   ` David Aguilar
2020-12-21 23:51                                     ` Code of conduct violation? Felipe Contreras
2020-12-22  7:13                                       ` Junio C Hamano
2020-12-22  9:58                                         ` Felipe Contreras
2020-12-22 15:01                                       ` Pratyush Yadav
2020-12-23  4:23                                         ` Felipe Contreras
2020-12-23  5:02                                           ` Junio C Hamano
2020-12-23  5:41                                             ` Felipe Contreras
2020-12-23 15:04                                               ` Nobody is THE one making contribution Junio C Hamano
2020-12-23 15:51                                                 ` Felipe Contreras
2020-12-23 20:56                                                   ` Junio C Hamano
2020-12-24  1:09                                                     ` Felipe Contreras
2020-12-24  2:01                                                   ` Ævar Arnfjörð Bjarmason
2020-12-24  5:19                                                     ` Felipe Contreras
2020-12-24 12:30                                                       ` Ævar Arnfjörð Bjarmason
2020-12-24 15:26                                                         ` Felipe Contreras
2020-12-24 22:57                                                           ` Junio C Hamano
2020-12-27 17:29                                                             ` Felipe Contreras
2020-12-27 18:30                                                               ` Junio C Hamano
2020-12-27 18:47                                                                 ` Felipe Contreras
2020-12-28 10:39                                                                   ` Junio C Hamano
2020-12-28 14:27                                                                     ` Felipe Contreras
2020-12-24 15:09                                                       ` Randall S. Becker
2020-12-24 15:37                                                         ` Felipe Contreras
2020-12-24 22:40                                                           ` Junio C Hamano
2020-12-24 21:00                                       ` Code of conduct violation? David Aguilar
2020-12-24 22:32                                         ` Felipe Contreras
2020-12-18 10:04                       ` [RFC/PATCH] mergetool: use resolved conflicts in all the views Junio C Hamano
2020-12-18 11:58                         ` Felipe Contreras
2020-12-19 18:52                           ` Junio C Hamano
2020-12-19 20:59                             ` Felipe Contreras
2020-12-20  6:44                               ` David Aguilar
2020-12-20  7:53                                 ` Felipe Contreras
2020-12-20 22:22                                   ` David Aguilar
2020-12-21  1:46                                     ` Felipe Contreras
2020-12-19  0:18                         ` Seth House
2020-12-16 23:41   ` Felipe Contreras
2020-12-17  5:19     ` Junio C Hamano
2020-12-17  5:43       ` Felipe Contreras
2020-12-17  2:35 ` [RFC/PATCH v2] " 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

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

  git send-email \
    --in-reply-to=xmqq5z50z0yu.fsf@gitster.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=davvid@gmail.com \
    --cc=felipe.contreras@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=j6t@kdbg.org \
    --cc=seth@eseth.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.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.