<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/git-mergetool--lib.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>2024-11-25T02:59:19Z</updated>
<entry>
<title>git-mergetool--lib.sh: add error message for unknown tool variant</title>
<updated>2024-11-25T02:59:19Z</updated>
<author>
<name>Philippe Blain</name>
<email>levraiphilippeblain@gmail.com</email>
</author>
<published>2024-11-22T19:50:21Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=acca46d12464cc64b623b104c04977d8db1a9591'/>
<id>urn:sha1:acca46d12464cc64b623b104c04977d8db1a9591</id>
<content type='text'>
In setup_tool, we check if the given tool is a known variant of a tool,
and quietly return with an error if not. This leads to the following
invocation quietly failing:

	git mergetool --tool=vimdiff4

Add an error message before returning in this case.

Signed-off-by: Philippe Blain &lt;levraiphilippeblain@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>git-mergetool--lib.sh: add error message if 'setup_user_tool' fails</title>
<updated>2024-11-25T02:59:19Z</updated>
<author>
<name>Philippe Blain</name>
<email>levraiphilippeblain@gmail.com</email>
</author>
<published>2024-11-22T19:50:20Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=bba503d43ef43a90597795e5e82018ba33d6a095'/>
<id>urn:sha1:bba503d43ef43a90597795e5e82018ba33d6a095</id>
<content type='text'>
In git-mergetool--lib.sh::setup_tool, we check if the given tool is a
known builtin tool, a known variant, or a user-defined tool by calling
setup_user_tool, and we return with the exit code from setup_user_tool
if it was called. setup_user_tool checks if {diff,merge}tool.$tool.cmd
is set and quietly returns with an error if not.

This leads to the following invocation quietly failing:

	git mergetool --tool=unknown

which is not very user-friendly. Adjust setup_tool to output an error
message before returning if setup_user_tool returned with an error.

Note that we do not check the result of the second call to
setup_user_tool in setup_tool, as this call is only meant to allow users
to redefine 'cmd' for a builtin tool; it is not an error if they have
not done so.

Note that this behaviour of quietly failing is a regression dating back
to de8dafbada (mergetool: break setup_tool out into separate
initialization function, 2021-02-09), as before this commit an unknown
mergetool would be diagnosed in get_merge_tool_path when called from
run_merge_tool.

Signed-off-by: Philippe Blain &lt;levraiphilippeblain@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>git-mergetool--lib.sh: use TOOL_MODE when erroring about unknown tool</title>
<updated>2024-11-25T02:59:19Z</updated>
<author>
<name>Philippe Blain</name>
<email>levraiphilippeblain@gmail.com</email>
</author>
<published>2024-11-22T19:50:19Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=00536761df113c8ad935c78bf407e427fce2f040'/>
<id>urn:sha1:00536761df113c8ad935c78bf407e427fce2f040</id>
<content type='text'>
In git-mergetool--lib.sh::get_merge_tool_path, we check if the chosen
tool is valid via valid_tool and exit with an error message if not. This
error message mentions "Unknown merge tool", even if the command the
user tried was 'git difftool --tool=unknown'. Use the global 'TOOL_MODE'
variable for a more correct error message.

Signed-off-by: Philippe Blain &lt;levraiphilippeblain@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<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>vimdiff: add tool documentation</title>
<updated>2022-04-03T22:09:52Z</updated>
<author>
<name>Fernando Ramos</name>
<email>greenfoo@u92.eu</email>
</author>
<published>2022-03-30T19:19:08Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=7b5cf8be180940ce099c8413d02fb5707d900708'/>
<id>urn:sha1:7b5cf8be180940ce099c8413d02fb5707d900708</id>
<content type='text'>
Running 'git {merge,diff}tool --tool-help' now also prints usage
information about the vimdiff tool (and its variants) instead of just
its name.

Two new functions ('diff_cmd_help()' and 'merge_cmd_help()') have been
added to the set of functions that each merge tool (ie. scripts found
inside "mergetools/") can overwrite to provided tool specific
information.

Right now, only 'mergetools/vimdiff' implements these functions, but
other tools are encouraged to do so in the future, specially if they
take configuration options not explained anywhere else (as it is the
case with the 'vimdiff' tool and the new 'layout' option)

Note that the function 'show_tool_names', used in the implementation of
'git mergetool --tool-help', is also used in Documentation/Makefile to
generate the list of allowed values for the configuration variables
'{diff,merge}.{gui,}tool'. Adjust the rule so its output is an Asciidoc
"description list" instead of a plain list, with the tool name as the
item and the newly added tool description as the description.

In addition, a section has been added to
"Documentation/git-mergetool.txt" to explain the new "layout"
configuration option with examples.

Helped-by: Philippe Blain &lt;levraiphilippeblain@gmail.com&gt;
Signed-off-by: Fernando Ramos &lt;greenfoo@u92.eu&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'sh/mergetool-hideresolved'</title>
<updated>2021-02-18T01:21:41Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2021-02-18T01:21:41Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=78a26cb7204ddb96a5f75f09e41fbefd81c85f59'/>
<id>urn:sha1:78a26cb7204ddb96a5f75f09e41fbefd81c85f59</id>
<content type='text'>
"git mergetool" feeds three versions (base, local and remote) of
a conflicted path unmodified.  The command learned to optionally
prepare these files with unconflicted parts already resolved.

* sh/mergetool-hideresolved:
  mergetool: add per-tool support and overrides for the hideResolved flag
  mergetool: break setup_tool out into separate initialization function
  mergetool: add hideResolved configuration
</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>Merge branch 'pb/mergetool-tool-help-fix'</title>
<updated>2021-01-16T05:48:46Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2021-01-16T05:48:46Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=073552d7ae5f34b93f9540787874c1ea0fff8051'/>
<id>urn:sha1:073552d7ae5f34b93f9540787874c1ea0fff8051</id>
<content type='text'>
Fix 2.29 regression where "git mergetool --tool-help" fails to list
all the available tools.

* pb/mergetool-tool-help-fix:
  mergetool--lib: fix '--tool-help' to correctly show available tools
</content>
</entry>
<entry>
<title>mergetool--lib: fix '--tool-help' to correctly show available tools</title>
<updated>2021-01-07T02:31:27Z</updated>
<author>
<name>Philippe Blain</name>
<email>levraiphilippeblain@gmail.com</email>
</author>
<published>2021-01-07T01:09:05Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=80f5a16798b7ff224aeab4a6b6e3627446071345'/>
<id>urn:sha1:80f5a16798b7ff224aeab4a6b6e3627446071345</id>
<content type='text'>
Commit 83bbf9b92e (mergetool--lib: improve support for vimdiff-style tool
variants, 2020-07-29) introduced a regression in the output of `git mergetool
--tool-help` and `git difftool --tool-help` [1].

In function 'show_tool_names' in git-mergetool--lib.sh, we loop over the
supported mergetools and their variants and accumulate them in the variable
'variants', separating them with a literal '\n'.

The code then uses 'echo $variants' to turn these '\n' into newlines, but this
behaviour is not portable, it just happens to work in some shells, like
dash(1)'s 'echo' builtin.

For shells in which 'echo' does not turn '\n' into newlines, the end
result is that the only tools that are shown are the existing variants
(except the last variant alphabetically), since the variants are
separated by actual newlines in '$variants' because of the several
'echo' calls in mergetools/{bc,vimdiff}::list_tool_variants.

Fix this bug by embedding an actual line feed into `variants` in
show_tool_names(). While at it, replace `sort | uniq` by `sort -u`.

To prevent future regressions, add a simple test that checks that a few
known tools are correctly shown (let's avoid counting the total number
of tools to lessen the maintenance burden when new tools are added or if
'--tool-help' learns additional logic, like hiding tools depending on
the current platform).

[1] https://lore.kernel.org/git/CADtb9DyozjgAsdFYL8fFBEWmq7iz4=prZYVUdH9W-J5CKVS4OA@mail.gmail.com/

Reported-by: Philippe Blain &lt;levraiphilippeblain@gmail.com&gt;
Based-on-patch-by: Johannes Sixt &lt;j6t@kdbg.org&gt;
Signed-off-by: Philippe Blain &lt;levraiphilippeblain@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
