<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/git-mergetool.sh, branch jch</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=jch</id>
<link rel='self' href='https://git.shady.money/git/atom?h=jch'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2023-04-06T04:03:29Z</updated>
<entry>
<title>mergetool: new config guiDefault supports auto-toggling gui by DISPLAY</title>
<updated>2023-04-06T04:03:29Z</updated>
<author>
<name>Tao Klerks</name>
<email>tao@klerks.biz</email>
</author>
<published>2023-03-18T15:27:43Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=42943b950e12f2d3e56688ecef1b0502e162b436'/>
<id>urn:sha1:42943b950e12f2d3e56688ecef1b0502e162b436</id>
<content type='text'>
When no merge.tool or diff.tool is configured or manually selected, the
selection of a default tool is sensitive to the DISPLAY variable; in a
GUI session a gui-specific tool will be proposed if found, and
otherwise a terminal-based one. This "GUI-optimizing" behavior is
important because a GUI can make a huge difference to a user's ability
to understand and correctly complete a non-trivial conflicting merge.

Some time ago the merge.guitool and diff.guitool config options were
introduced to enable users to configure both a GUI tool, and a non-GUI
tool (with fallback if no GUI tool configured), in the same environment.

Unfortunately, the --gui argument introduced to support the selection of
the guitool is still explicit. When using configured tools, there is no
equivalent of the no-tool-configured "propose a GUI tool if we are in a GUI
environment" behavior.

As proposed in &lt;xmqqmtb8jsej.fsf@gitster.g&gt;, introduce new configuration
options, difftool.guiDefault and mergetool.guiDefault, supporting a special
value "auto" which causes the corresponding tool or guitool to be selected
depending on the presence of a non-empty DISPLAY value. Also support "true"
to say "default to the guitool (unless --no-gui is passed on the
commandline)", and "false" as the previous default behavior when these new
configuration options are not specified.

Signed-off-by: Tao Klerks &lt;tao@klerks.biz&gt;
Acked-by: David Aguilar &lt;davvid@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>mergetool: do not enable hideResolved by default</title>
<updated>2021-03-13T23:30:29Z</updated>
<author>
<name>Jonathan Nieder</name>
<email>jrnieder@gmail.com</email>
</author>
<published>2021-03-13T08:38:48Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=b2a51c1b03c44bd888e2f65c764dced571266482'/>
<id>urn:sha1:b2a51c1b03c44bd888e2f65c764dced571266482</id>
<content type='text'>
When 98ea309b3f (mergetool: add hideResolved configuration,
2021-02-09) introduced the mergetool.hideResolved setting to reduce
the clutter in viewing non-conflicted sections of files in a
mergetool, it enabled it by default, explaining:

    No adverse effects were noted in a small survey of popular mergetools[1]
    so this behavior defaults to `true`.

In practice, alas, adverse effects do appear.  A few issues:

1. No indication is shown in the UI that the base, local, and remote
   versions shown have been modified by additional resolution.  This
   is inherent in the design: the idea of mergetool.hideResolved is to
   convince a mergetool that expects pristine local, base, and remote
   files to show partially resolved verisons of those files instead;
   there is no additional source of information accessible to the
   mergetool to see where the resolution has happened.

   (By contrast, a mergetool generating the partial resolution from
   conflict markers for itself would be able to hilight the resolved
   sections with a different color.)

   A user accustomed to seeing the files without partial resolution
   gets no indication that this behavior has changed when they upgrade
   Git.

2. If the computed merge did not line up the files correctly (for
   example due to repeated sections in the file), the partially
   resolved files can be misleading and do not have enough information
   to reconstruct what happened and compute the correct merge result.

3. Resolving a conflict can involve information beyond the textual
   conflict.  For example, if the local and remote versions added
   overlapping functionality in different ways, seeing the full
   unresolved versions of each alongside the base gives information
   about each side's intent that makes it possible to come up with a
   resolution that combines those two intents.  By contrast, when
   starting with partially resolved versions of those files, one can
   produce a subtly wrong resolution that includes redundant extra
   code added by one side that is not needed in the approach taken
   on the other.

All that said, a user wanting to focus on textual conflicts with
reduced clutter can still benefit from mergetool.hideResolved=true as
a way to deemphasize sections of the code that resolve cleanly without
requiring any changes to the invoked mergetool.  The caveats described
above are reduced when the user has explicitly turned this on, because
then the user is aware of them.

Flip the default to 'false'.

Reported-by: Dana Dahlstrom &lt;dahlstrom@google.com&gt;
Helped-by: Seth House &lt;seth@eseth.com&gt;
Signed-off-by: Jonathan Nieder &lt;jrnieder@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>mergetool: add per-tool support and overrides for the hideResolved flag</title>
<updated>2021-02-09T22:09:16Z</updated>
<author>
<name>Seth House</name>
<email>seth@eseth.com</email>
</author>
<published>2021-02-09T20:07:12Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=9d9cf230317f7fe7cb153f61b537e6e9bef22e3b'/>
<id>urn:sha1:9d9cf230317f7fe7cb153f61b537e6e9bef22e3b</id>
<content type='text'>
Add a per-tool override flag so that users may enable the flag for one
tool and disable it for another by setting
`mergetool.&lt;tool&gt;.hideResolved` to `false`.

In addition, the author or maintainer of a mergetool may optionally
override the default `hideResolved` value for that mergetool. If the
`mergetools/&lt;tool&gt;` shell script contains a `hide_resolved_enabled`
function it will be called when the mergetool is invoked and the return
value will be used as the default for the `hideResolved` flag.

    hide_resolved_enabled () {
        return 1
    }

Disabling may be desirable if the mergetool wants or needs access to the
original, unmodified 'LOCAL' and 'REMOTE' versions of the conflicted
file. For example:

- A tool may use a custom conflict resolution algorithm and prefer to
  ignore the results of Git's conflict resolution.
- A tool may want to visually compare/constrast the version of the file
  from before the merge (saved to 'LOCAL', 'REMOTE', and 'BASE') with
  Git's conflict resolution results (saved to 'MERGED').

Helped-by: Johannes Sixt &lt;j6t@kdbg.org&gt;
Helped-by: Junio C Hamano &lt;gitster@pobox.com&gt;
Signed-off-by: Seth House &lt;seth@eseth.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>mergetool: break setup_tool out into separate initialization function</title>
<updated>2021-02-09T22:09:16Z</updated>
<author>
<name>Seth House</name>
<email>seth@eseth.com</email>
</author>
<published>2021-02-09T20:07:11Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=de8dafbada811bc1bc8e1288541931f3c5406231'/>
<id>urn:sha1:de8dafbada811bc1bc8e1288541931f3c5406231</id>
<content type='text'>
This is preparation for the following commit where we need to source the
mergetool shell script to look for overrides before `run_merge_tool` is
called. Previously `run_merge_tool` both sourced that script and invoked
the mergetool.

In the case of the following commit, we need the result of the
`hide_resolved` override, if present, before we actually run
`run_merge_tool`.

The new `initialize_merge_tool` wrapper is exposed and documented as
a public interface for consistency with the existing `run_merge_tool`
which is also public. Although `setup_tool` could instead be exposed
directly, the related `setup_user_tool` would probably also want to be
elevated to match and this felt the cleanest to me.

Signed-off-by: Seth House &lt;seth@eseth.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>mergetool: add hideResolved configuration</title>
<updated>2021-02-09T22:09:16Z</updated>
<author>
<name>Seth House</name>
<email>seth@eseth.com</email>
</author>
<published>2021-02-09T20:07:10Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=98ea309b3fa4818c1591b9071925ccb22c2e786b'/>
<id>urn:sha1:98ea309b3fa4818c1591b9071925ccb22c2e786b</id>
<content type='text'>
The purpose of a mergetool is to help the user resolve any conflicts
that Git cannot automatically resolve. If there is a conflict that must
be resolved manually Git will write a file named MERGED which contains
everything Git was able to resolve by itself and also everything that it
was not able to resolve wrapped in conflict markers.

One way to think of MERGED is as a two- or three-way diff. If each
"side" of the conflict markers is separately extracted an external tool
can represent those conflicts as a side-by-side diff.

However many mergetools instead diff LOCAL and REMOTE both of which
contain versions of the file from before the merge. Since the conflicts
Git resolved automatically are not present it forces the user to
manually re-resolve those conflicts. Some mergetools also show MERGED
but often only for reference and not as the focal point to resolve the
conflicts.

This adds a `mergetool.hideResolved` flag that will overwrite LOCAL and
REMOTE with each corresponding "side" of a conflicted file and thus hide
all conflicts that Git was able to resolve itself. Overwriting these
files will immediately benefit any mergetool that uses them without
requiring any changes to the tool.

No adverse effects were noted in a small survey of popular mergetools[1]
so this behavior defaults to `true`. However it can be globally disabled
by setting `mergetool.hideResolved` to `false`.

[1] https://www.eseth.org/2020/mergetools.html
    https://github.com/whiteinge/eseth/blob/c884424769fffb05d87afb33b2cf80cecb4044c3/2020/mergetools.md

Original-implementation-by: Felipe Contreras &lt;felipe.contreras@gmail.com&gt;
Signed-off-by: Seth House &lt;seth@eseth.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>mergetool: use shell variable magic instead of `awk`</title>
<updated>2019-06-12T20:20:56Z</updated>
<author>
<name>Johannes Sixt</name>
<email>j6t@kdbg.org</email>
</author>
<published>2019-06-12T16:33:48Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=7e6d6f7610965906d071022615bf64f14c60c0d2'/>
<id>urn:sha1:7e6d6f7610965906d071022615bf64f14c60c0d2</id>
<content type='text'>
git-mergetool spawns an enormous amount of processes. For this reason,
the test script, t7610, is exceptionally slow, in particular, on
Windows. Most of the processes are invocations of git. There are
also some that can be replaced with shell builtins. Avoid repeated
calls of `git ls-files` and `awk`.

Signed-off-by: Johannes Sixt &lt;j6t@kdbg.org&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>mergetool: dissect strings with shell variable magic instead of `expr`</title>
<updated>2019-06-12T20:20:56Z</updated>
<author>
<name>Johannes Sixt</name>
<email>j6t@kdbg.org</email>
</author>
<published>2019-06-12T16:33:47Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=8b014655105e27d44cf62f61dd6b24322a57048f'/>
<id>urn:sha1:8b014655105e27d44cf62f61dd6b24322a57048f</id>
<content type='text'>
git-mergetool spawns an enormous amount of processes. For this reason,
the test script, t7610, is exceptionally slow, in particular, on
Windows. Most of the processes are invocations of git. There are
also some that can be replaced with shell builtins. Do so with `expr`.

Signed-off-by: Johannes Sixt &lt;j6t@kdbg.org&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>mergetool: use get_merge_tool function</title>
<updated>2019-05-13T14:11:59Z</updated>
<author>
<name>Denton Liu</name>
<email>liu.denton@gmail.com</email>
</author>
<published>2019-04-29T06:21:08Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=05fb8726cccc74908853c166248ff9b6abdafae5'/>
<id>urn:sha1:05fb8726cccc74908853c166248ff9b6abdafae5</id>
<content type='text'>
In git-mergetool, the logic for getting which merge tool to use is
duplicated in git-mergetool--lib, except for the fact that it needs to
know whether the tool was guessed or not.

Rewrite `get_merge_tool` to return whether or not the tool was guessed
through the return code and make git-mergetool call this function
instead of duplicating the logic. Note that 1 was chosen to be the
return code of when a tool is guessed because it seems like a slightly
more abnormal condition than getting a tool that's explicitly specified
but this is completely arbitrary.

Also, let `$GIT_MERGETOOL_GUI` be set to determine whether or not the
guitool will be selected.

This change is not completely backwards compatible as there may be
external users of git-mergetool--lib. However, only one user,
git-diffall[1], was found from searching GitHub and Google, and this
tool is superseded by `git difftool --dir-diff` anyway. It seems very
unlikely that there exists an external caller that would take into
account the return code of `get_merge_tool` as it would always return 0
before this change so this change probably does not affect any external
users.

[1]: https://github.com/thenigan/git-diffall

Signed-off-by: Denton Liu &lt;liu.denton@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>mergetool: accept -g/--[no-]gui as arguments</title>
<updated>2018-10-25T05:01:10Z</updated>
<author>
<name>Denton Liu</name>
<email>liu.denton@gmail.com</email>
</author>
<published>2018-10-24T16:25:31Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=063f2bdbf767dd24bc0a35b5476d8025ee8646c7'/>
<id>urn:sha1:063f2bdbf767dd24bc0a35b5476d8025ee8646c7</id>
<content type='text'>
In line with how difftool accepts a -g/--[no-]gui option, make mergetool
accept the same option in order to use the `merge.guitool` variable to
find the default mergetool instead of `merge.tool`.

Signed-off-by: Denton Liu &lt;liu.denton@gmail.com&gt;
Signed-off-by: Anmol Mago &lt;anmolmago@gmail.com&gt;
Signed-off-by: Brian Ho &lt;briankyho@gmail.com&gt;
Signed-off-by: David Lu &lt;david.lu97@outlook.com&gt;
Signed-off-by: Ryan Wang &lt;shirui.wang@hotmail.com&gt;
Acked-by: David Aguilar &lt;davvid@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>mergetool: don't suggest to continue after last file</title>
<updated>2018-08-13T19:11:19Z</updated>
<author>
<name>Nicholas Guriev</name>
<email>guriev-ns@ya.ru</email>
</author>
<published>2018-08-13T05:09:29Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=d651a54b8a22a307f5b061ba50c5348ae31e861c'/>
<id>urn:sha1:d651a54b8a22a307f5b061ba50c5348ae31e861c</id>
<content type='text'>
Eliminate an unnecessary prompt to continue after failed merger, by
not calling the prompt_after_failed_merge function when only one
iteration remains.

Uses positional parameters to count files in the list to make it
easier to see if we have any more paths to process from within the
loop.

Signed-off-by: Nicholas Guriev &lt;guriev-ns@ya.ru&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
