Subject: Re: trustExitCode doesn't apply to vimdiff mergetool

From: Junio C Hamano <[email-masked]>
Date: Mon, 28 Nov 2016 09:17:41 -0800

David Aguilar <[email-masked]> writes:

> deltawalker, diffmerge, emerge, kdiff3, kompare, and tkdiff originally
> provided behavior that matched trustExitCode=true.
>
> The default for all tools is trustExitCode=false, which conflicts with
> these tools' defaults.  Allow tools to advertise their own default value
> for trustExitCode so that users do not need to opt-in to the original
> behavior.
>
> While this makes the default inconsistent between tools, it can still be
> overridden, and it makes it consistent with the current Git behavior.

I think this is sensible, because the way I look at this issue is
that in an ideal world, we would want all tool backends consistently
give us usable exit codes, but some tools are known to give unusable
exit codes, so we ignore their exit codes by default.

As to the implementation, I think you can reduce the duplication by
having each tool backend 

 - export a new function that echos "true" or "false"; or
 - export a new function that returns true or false; or
 - set a variable whose value is either "true" or "false"

and use that from the trust_exit_code() in git-mergetool--lib.sh.
Something like this (for the second alternative).

    trust_exit_code () {
        if git config --bool "mergtool.$.trustExitCode"
	then
		:; # OK
	elif mergetool_exitcode_trustable
	then
		echo true
	else
		echo false
        fi
    }