Re: [BUG] Regression in 'git mergetool --tool-help'
- From
Philippe Blain <levraiphilippeblain@gmail.com>
- Date
- Dec 20, 2020, 23:47 UTC
- Message-ID
- <2e7485b6-86d9-4de2-a823-dd84fc7386b0@gmail.com>
- In-Reply-To
- <a9e6f3aa-e88e-6cc2-fb16-c26bdd3bf4d3@web.de>
Hi everyone,
Le 2020-12-20 à 11:23, René Scharfe a écrit :
Show 59 quoted lines
> Am 20.12.20 um 11:28 schrieb Johannes Sixt:
>> Am 20.12.20 um 03:13 schrieb Philippe Blain:
>>> Thanks for both answers. Felipe's solution does the trick, but Junio's
>>> does not;
>>> it seems we do have to have a newline there. The following also works,
>>> and I think
>>> is portable:
>>>
>>> diff --git i/git-mergetool--lib.sh w/git-mergetool--lib.sh
>>> index 2defef28cd..6f03975493 100644
>>> --- i/git-mergetool--lib.sh
>>> +++ w/git-mergetool--lib.sh
>>> @@ -46,7 +46,7 @@ show_tool_names () {
>>> while read scriptname
>>> do
>>> setup_tool "$scriptname" 2>/dev/null
>>> - variants="$variants$(list_tool_variants)\n"
>>> + variants="$(echo "$variants" && list_tool_variants)"
>>> done
>>> variants="$(echo "$variants" | sort | uniq)"
>>>
>>> I figured out what was different between the different Ubuntu versions I
>>> was testing:
>>> the Ubuntu 14 and 18 systems have Bash as /bin/sh, but my Ubuntu 20 system
>>> has /usr/bin/dash as /bin/sh (the default for Ubuntu these days).
>>>
>>> I'll try to send a formal patch with the diff above, time permitting...
>>
>> If possible, please do not use sub-processes like in your suggested
>> patch. How about
>>
>> variants="$variants
>> $(list_tool_variants)"
>
> This still starts a subshell in the last line. How about something
> like this?
>
> diff --git a/git-mergetool--lib.sh b/git-mergetool--lib.sh
> index 7225abd811..79d5ed1fa9 100644
> --- a/git-mergetool--lib.sh
> +++ b/git-mergetool--lib.sh
> @@ -46,11 +46,9 @@ show_tool_names () {
> while read scriptname
> do
> setup_tool "$scriptname" 2>/dev/null
> - variants="$variants$(list_tool_variants)\n"
> - done
> - variants="$(echo "$variants" | sort | uniq)"
> -
> - for toolname in $variants
> + list_tool_variants
> + done | sort | uniq |
> + while read toolname
> do
> if setup_tool "$toolname" 2>/dev/null &&
> (eval "$condition" "$toolname")
>
> It requires setup_tool to be silent, though.
>Thanks René and Johannes for two additional suggestions; both work correctly. Junio, I retried yours and verified my quoting and I confirm it does not work.
I think I prefer René's suggestion.
Thanks all,
Philippe.