git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2] mergetool--lib: fix '--tool-help' to correctly show available tools

From
Philippe Blain <levraiphilippeblain@gmail.com>
Date
Jan 6, 2021, 13:34 UTC
Message-ID
<11b3c261-14e6-0293-02a6-92bd1ea680d2@gmail.com>
In-Reply-To
<20210106131651.GQ8396@szeder.dev>
Hi Gábor,
Le 2021-01-06 à 08:16, SZEDER Gábor a écrit :
Show 34 quoted lines
> On Mon, Dec 28, 2020 at 07:41:44PM +0000, Philippe Blain via GitGitGadget wrote:
>> To prevent future regressions, add a simple test that counts the number
>> of tools shown by 'git mergetool --tool-help', irrespective of their
>> installed status, by making use of the fact that mergetools are listed
>> by 'git mergetool --tool-help' on lines starting with tabs. Prefix the
>> `git config` commands used at the beginning of the test to remove the
>> fake tools used by the previous test with 'test_might_fail' so that the
>> test can be run independantly of the previous test without failing.
> 
>> diff --git a/t/t7610-mergetool.sh b/t/t7610-mergetool.sh
>> index 70afdd06fa7..ebd3af139e5 100755
>> --- a/t/t7610-mergetool.sh
>> +++ b/t/t7610-mergetool.sh
>> @@ -828,4 +828,14 @@ test_expect_success 'mergetool -Oorder-file is honored' '
>>   	test_cmp expect actual
>>   '
>>   
>> +test_expect_success 'mergetool --tool-help shows all recognized tools' '
>> +	# Remove fake tools added in previous tests
>> +	test_might_fail git config --unset merge.tool &&
>> +	test_might_fail git config --remove-section mergetool.mytool &&
>> +	test_might_fail git config --remove-section mergetool.mybase &&
>> +	git mergetool --tool-help >output &&
>> +	grep "$(printf "\t")" output >mergetools &&
>> +	test_line_count = 30 mergetools
>> +'
> 
> This new test fails when the topic 'pb/mergetool-tool-help-fix' is
> built and tested in isolation, because 'git mergetool --tool-help'
> lists only 29 tools instead of the expected 30.  The reason is that
> 'pb/mergetool-tool-help-fix' doesn't include commit 6bc9082c0f
> (mergetools/bc: add `bc4` to the alias list for Beyond Compare,
> 2020-11-11), which added that 30th tool (and is already part of
> v2.30.0).

Indeed. The branch I submitted is based on v2.30.0-rc2, but Junio based pb/mergetool-tool-help-fix on v2.29.0-rc0~165^2, so the number of supported tools is "wrong".

Show 6 quoted lines
> 
> It also makes me wonder whether this is the right way to test this
> fix, because we'll need to adjust this test case every time we add
> support for a new merge tool (which arguably doesn't happen that
> often, but since we are already at 30 it doesn't seem to be that rare
> either).

Yes, it does. I thought about that, and I came to the conclusion that it was the easiest way to prevent a regression like the one this patch is fixing. I tought about doing it a different way, like having the test count the available mergetools itself, and comparing the number of tools shown by '--tool-help' with that number, but I chose not to do that because it seemed to be more complicated (and would end up kind of re-implementing what '--tool-help' does, in a way...)

If you think of another of how we could test it, I can try it.
Cheers,
Philippe.
Previous: SZEDER GáborNext: Junio C Hamano
Message 4 of 10 in “mergetool--lib: fix '--tool-help' to correctly show available tools”
  1. mergetool--lib: fix '--tool-help' to correctly show available toolsPhilippe Blain via GitGitGadget, Dec 28, 2020
  2. mergetool--lib: fix '--tool-help' to correctly show available toolsPhilippe Blain via GitGitGadget, Dec 28, 2020
  3. SZEDER GáborJan 6, 2021
  4. Philippe BlainJan 6, 2021
  5. Junio C HamanoJan 6, 2021
  6. Philippe BlainJan 6, 2021
  7. Junio C HamanoJan 6, 2021
  8. Philippe BlainJan 7, 2021
  9. mergetool--lib: fix '--tool-help' to correctly show available toolsPhilippe Blain via GitGitGadget, Jan 7, 2021
  10. Philippe BlainJan 7, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.