Subject: Re: [PATCH v2 3/3] diff: let external diffs report that changes are uninteresting

From: Junio C Hamano <[email-masked]>
Date: Thu, 06 Jun 2024 08:49:00 -0700

René Scharfe <[email-masked]> writes:

>>> +diff.trustExitCode::
>>> +	If this boolean value is set to true then the `diff.external`
>>> +	command is expected to return exit code 1 if it finds
>>> +	significant changes and 0 if it doesn't, like diff(1).  If it's
>>> +	false then the `diff.external` command is expected to always
>>> +	return exit code 0.  Defaults to false.
>>
>> I find this somewhat unclear. What are the consequences when this value
>> is set to false, but the command exits with code other than 0? Is it
>>
>>     If it's false then any exit code other than 0 of the `diff.external`
>>     command is treated as an error.
>
> Yes, unexpected exit codes are reported as errors.
>
> If trustExitCode is false and --quiet is given then the execution of
> external diffs is skipped, so in that situation there is no exit code to
> expect, though.  Not sure how to express it concisely, though.  This
> attempt looks a bit bloated:
>
> --quiet::
>         Disable all output of the program. Implies `--exit-code`.
>         Disables execution of external diff helpers whose exit code
>         is not trusted, i.e. their respective configuration option
> 	`diff.trustExitCode` or `diff.<driver>.trustExitCode` or
> 	environment variable `GIT_EXTERNAL_DIFF_TRUST_EXIT_CODE` is
> 	false.
>
> Might be worth documenting this original behavior somehow, anyway.  It
> makes sense in hindsight, but surprised me a bit when I wrote the tests.

Yes.  The explanation of trustExitCode makes sense as an explanation
of what the variable means (i.e. if set, we pay attention to the
exit code of the external diff driver, otherwise a non-zero exit is
an error), but I suspect that readers are _more_ interested in how
the external diff driver contributes to the answer to the "has this
path been changed?" question when the variable is on and off.  And
the above description of "--quiet" does help answer that question
somewhat.