git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/2] mergetool: avoid letting `list_tool_variants` break user-defined setups

From
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
Date
Nov 11, 2020, 20:33 UTC
Message-ID
<c157c07d5d4917e6eef6717894f61c54cbc9af22.1605126798.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.787.git.1605126798.gitgitgadget@gmail.com>
From: Johannes Schindelin <johannes.schindelin@gmx.de>

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 <johannes.schindelin@gmx.de>
---
 git-mergetool--lib.sh | 4 ++++
 1 file changed, 4 insertions(+)
diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh
index 2defef28cd..7225abd811 100644
--- a/git-mergetool--lib.sh
+++ b/git-mergetool--lib.sh
@@ -138,6 +138,10 @@ setup_user_tool () {
 	merge_cmd () {
 		( eval $merge_tool_cmd )
 	}
+
+	list_tool_variants () {
+		echo "$tool"
+	}
 }
 
 setup_tool () {
-- 
gitgitgadget
Previous: Johannes Schindelin via GitGitGadgetNext: Junio C Hamano
Message 2 of 4 in “difftool: fix user-defined Beyond Compare setups”
  1. 0/2 difftool: fix user-defined Beyond Compare setupsJohannes Schindelin via GitGitGadget, Nov 11, 2020
  2. 2/2 mergetool: avoid letting `list_tool_variants` break user-defined setupsJohannes Schindelin via GitGitGadget, Nov 11, 2020
  3. Junio C HamanoNov 11, 2020
  4. 1/2 mergetools/bc: add `bc4` to the alias list for Beyond CompareJohannes Schindelin via GitGitGadget, Nov 11, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.