diff mbox series

[2/5] git-mergetool--lib.sh: use TOOL_MODE when erroring about unknown tool

Message ID 6f7f553b283078ba3c81190686b150a87d901240.1731459128.git.gitgitgadget@gmail.com (mailing list archive)
State New
Headers show
Series git-mergetool: improve error code paths and messages | expand

Commit Message

Philippe Blain Nov. 13, 2024, 12:52 a.m. UTC
From: Philippe Blain <levraiphilippeblain@gmail.com>

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 <levraiphilippeblain@gmail.com>
---
 git-mergetool--lib.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Junio C Hamano Nov. 13, 2024, 1:27 a.m. UTC | #1
"Philippe Blain via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Philippe Blain <levraiphilippeblain@gmail.com>
>
> 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.

Makes sense.  Is this something we can easily test to catch future
regression, or is it too trivial to matter?

I wouldn't mind if the answer were "the latter" ;-)

Thanks.

> Signed-off-by: Philippe Blain <levraiphilippeblain@gmail.com>
> ---
>  git-mergetool--lib.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh
> index 1ff26170ffc..269a60ea44c 100644
> --- a/git-mergetool--lib.sh
> +++ b/git-mergetool--lib.sh
> @@ -474,7 +474,7 @@ get_merge_tool_path () {
>  	merge_tool="$1"
>  	if ! valid_tool "$merge_tool"
>  	then
> -		echo >&2 "Unknown merge tool $merge_tool"
> +		echo >&2 "Unknown $TOOL_MODE tool $merge_tool"
>  		exit 1
>  	fi
>  	if diff_mode
diff mbox series

Patch

diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh
index 1ff26170ffc..269a60ea44c 100644
--- a/git-mergetool--lib.sh
+++ b/git-mergetool--lib.sh
@@ -474,7 +474,7 @@  get_merge_tool_path () {
 	merge_tool="$1"
 	if ! valid_tool "$merge_tool"
 	then
-		echo >&2 "Unknown merge tool $merge_tool"
+		echo >&2 "Unknown $TOOL_MODE tool $merge_tool"
 		exit 1
 	fi
 	if diff_mode