Web lists-archives.com

Re: [PATCH v3 6/6] difftool: fallback on merge.guitool




Denton Liu <liu.denton@xxxxxxxxx> writes:

> @@ -734,8 +728,8 @@ int cmd_difftool(int argc, const char **argv, const char *prefix)
>  	if (use_gui_tool + !!difftool_cmd + !!extcmd > 1)
>  		die(_("--gui, --tool and --extcmd are mutually exclusive"));
>  
> -	if (use_gui_tool && diff_gui_tool && *diff_gui_tool)
> -		setenv("GIT_DIFF_TOOL", diff_gui_tool, 1);
> +	if (use_gui_tool)
> +		setenv("GIT_MERGETOOL_GUI", "true", 1);
>  	else if (difftool_cmd) {
>  		if (*difftool_cmd)
>  			setenv("GIT_DIFF_TOOL", difftool_cmd, 1);

So unless difftool_cmd is given explicitly, we'll let the scripted
difftool--helper to let merge_tool=$(get_merge_tool) to pick the
tool, which will use the same logic you wrote in the step 2/6.

OK, that makes sense.

What was preventing the get_configured_merge_tool updated in step
2/6 from getting called in difftool was the exporting of
GIT_DIFF_TOOL we see abovethat was removed by this step.

Which also makes sense.

> diff --git a/t/t7800-difftool.sh b/t/t7800-difftool.sh
> index 107f31213d..ae90701a12 100755
> --- a/t/t7800-difftool.sh
> +++ b/t/t7800-difftool.sh
> @@ -279,11 +279,27 @@ test_expect_success 'difftool + mergetool config variables' '
>  	echo branch >expect &&
>  	git difftool --no-prompt branch >actual &&
>  	test_cmp expect actual &&
> +	git difftool --gui --no-prompt branch >actual &&
> +	test_cmp expect actual &&
>  
>  	# set merge.tool to something bogus, diff.tool to test-tool
>  	test_config merge.tool bogus-tool &&
>  	test_config diff.tool test-tool &&
>  	git difftool --no-prompt branch >actual &&
> +	test_cmp expect actual &&
> +	git difftool --gui --no-prompt branch >actual &&
> +	test_cmp expect actual &&
> +
> +	# set merge.tool, diff.tool to something bogus, merge.guitool to test-tool
> +	test_config diff.tool bogus-tool &&
> +	test_config merge.guitool test-tool &&
> +	git difftool --gui --no-prompt branch >actual &&
> +	test_cmp expect actual &&
> +
> +	# set merge.tool, diff.tool, merge.guitool to something bogus, diff.guitool to test-tool
> +	test_config merge.guitool bogus-tool &&
> +	test_config diff.guitool test-tool &&
> +	git difftool --gui --no-prompt branch >actual &&
>  	test_cmp expect actual
>  '