<feed xmlns='http://www.w3.org/2005/Atom'>
<title>git/git-mergetool--lib.sh, branch v2.30.2</title>
<subtitle>Mirror of https://git.kernel.org/pub/scm/git/git.git/
</subtitle>
<id>https://git.shady.money/git/atom?h=v2.30.2</id>
<link rel='self' href='https://git.shady.money/git/atom?h=v2.30.2'/>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/'/>
<updated>2021-02-06T00:31:24Z</updated>
<entry>
<title>Merge branch 'pb/mergetool-tool-help-fix' into maint</title>
<updated>2021-02-06T00:31:24Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2021-02-06T00:31:24Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=64971f0ac0200d3bb53cb19e7367cf57a40ae1fc'/>
<id>urn:sha1:64971f0ac0200d3bb53cb19e7367cf57a40ae1fc</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>
<entry>
<title>mergetool: avoid letting `list_tool_variants` break user-defined setups</title>
<updated>2020-11-11T21:00:11Z</updated>
<author>
<name>Johannes Schindelin</name>
<email>johannes.schindelin@gmx.de</email>
</author>
<published>2020-11-11T20:33:18Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=12026f46e73ba09b8c403079bccc72a3b85e8dc9'/>
<id>urn:sha1:12026f46e73ba09b8c403079bccc72a3b85e8dc9</id>
<content type='text'>
In 83bbf9b92ea8 (mergetool--lib: improve support for vimdiff-style tool
variants, 2020-07-29), we introduced a `list_tool_variants` function
in the spirit of Postel's Law: be lenient in what you accept as input.
In this particular instance, we wanted to allow not only `bc` but also
`bc3` as name for the Beyond Compare tool.

However, what this patch overlooked is that it is totally allowed for
users to override the defaults in `mergetools/`. But now that we strip
off trailing digits, the name that the user gave the tool might not
actually be in the list produced by `list_tool_variants`.

So let's do the same as for the `diff_cmd` and the `merge_cmd`: override
it with the trivial version in case a user-defined setup was detected.

Signed-off-by: Johannes Schindelin &lt;johannes.schindelin@gmx.de&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>mergetools: add support for nvimdiff (neovim) family</title>
<updated>2020-07-29T21:44:49Z</updated>
<author>
<name>pudinha</name>
<email>rogi@skylittlesystem.org</email>
</author>
<published>2020-07-29T21:31:13Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=11868978c7c80d3c29071b29e7964e3d62523819'/>
<id>urn:sha1:11868978c7c80d3c29071b29e7964e3d62523819</id>
<content type='text'>
Signed-off-by: pudinha &lt;rogi@skylittlesystem.org&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>mergetool--lib: improve support for vimdiff-style tool variants</title>
<updated>2020-07-29T21:44:46Z</updated>
<author>
<name>pudinha</name>
<email>rogi@skylittlesystem.org</email>
</author>
<published>2020-07-29T21:31:12Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=83bbf9b92ea8a10a60f44369a200b39ce5db78cd'/>
<id>urn:sha1:83bbf9b92ea8a10a60f44369a200b39ce5db78cd</id>
<content type='text'>
The merge tools vimdiff2, vimdiff3, gvimdiff2, gvimdiff3 and bc3 are all
variants of the main tools vimdiff and bc. They are implemented in the
main and a one-liner script that just sources it exist for each.

Allow variants ending in [0-9] to be correctly wired without the need
for such one-liners, so instead of 5 scripts, only 1 (gvimdiff) is
needed.

Signed-off-by: pudinha &lt;rogi@skylittlesystem.org&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
<entry>
<title>Merge branch 'dl/difftool-mergetool'</title>
<updated>2019-05-19T07:45:30Z</updated>
<author>
<name>Junio C Hamano</name>
<email>gitster@pobox.com</email>
</author>
<published>2019-05-19T07:45:30Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=85ac27e04fd0cf1d086028e87f69ffb498c1451b'/>
<id>urn:sha1:85ac27e04fd0cf1d086028e87f69ffb498c1451b</id>
<content type='text'>
Update "git difftool" and "git mergetool" so that the combinations
of {diff,merge}.{tool,guitool} configuration variables serve as
fallback settings of each other in a sensible order.

* dl/difftool-mergetool:
  difftool: fallback on merge.guitool
  difftool: make --gui, --tool and --extcmd mutually exclusive
  mergetool: fallback to tool when guitool unavailable
  mergetool--lib: create gui_mode function
  mergetool: use get_merge_tool function
  t7610: add mergetool --gui tests
  t7610: unsuppress output
</content>
</entry>
<entry>
<title>mergetool: fallback to tool when guitool unavailable</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:14Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=60aced3dfa68df60952fed28c4ae63a5bbda0275'/>
<id>urn:sha1:60aced3dfa68df60952fed28c4ae63a5bbda0275</id>
<content type='text'>
In git-difftool, if the tool is called with --gui but `diff.guitool` is
not set, it falls back to `diff.tool`. Make git-mergetool also fallback
from `merge.guitool` to `merge.tool` if the former is undefined.

If git-difftool, when called with `--gui`, were to use
`get_configured_mergetool` in a future patch, it would also get the
fallback behavior in the following precedence:

1. diff.guitool
2. merge.guitool
3. diff.tool
4. merge.tool

The behavior for when difftool or mergetool are called without `--gui`
should be identical with or without this patch.

Note that the search loop could be written as

	sections="merge"
	keys="tool"
	if diff_mode
	then
		sections="diff $sections"
	fi
	if gui_mode
	then
		keys="guitool $keys"
	fi

	merge_tool=$(
		IFS=' '
		for key in $keys
		do
			for section in $sections
			do
				selected=$(git config $section.$key)
				if test -n "$selected"
				then
					echo "$selected"
					return
				fi
			done
		done)

which would make adding a mode in the future much easier. However,
adding a new mode will likely never happen as it is highly discouraged
so, as a result, it is written in its current form so that it is more
readable for future readers.

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--lib: create gui_mode 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:11Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=884630b2e2634969656faabc7f4e33cab2e32b35'/>
<id>urn:sha1:884630b2e2634969656faabc7f4e33cab2e32b35</id>
<content type='text'>
Before, in `get_configured_merge_tool`, we would test the value of the
first argument directly, which corresponded to whether we were using
guitool. However, since `$GIT_MERGETOOL_GUI` is available as an
environment variable, create the `gui_mode` function which increases the
clarify of functions which use it.

While we're at it, add a space before `()` in function definitions to
fix the style.

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: 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>mergetools: add support for smerge (Sublime Merge)</title>
<updated>2019-04-04T09:21:25Z</updated>
<author>
<name>David Aguilar</name>
<email>davvid@gmail.com</email>
</author>
<published>2019-04-04T07:34:38Z</published>
<link rel='alternate' type='text/html' href='https://git.shady.money/git/commit/?id=eb12adc74cf22add318f884072be2071d181abaa'/>
<id>urn:sha1:eb12adc74cf22add318f884072be2071d181abaa</id>
<content type='text'>
Teach difftool and mergetool about the Sublime Merge "smerge" command.

Signed-off-by: David Aguilar &lt;davvid@gmail.com&gt;
Signed-off-by: Junio C Hamano &lt;gitster@pobox.com&gt;
</content>
</entry>
</feed>
