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

Re: [PATCH v2 2/5] Use -y where possible in test t7610-mergetool

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 3, 2017, 19:39 UTC
Message-ID
<xmqqd1dy880d.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<20170303134022.GA6258@arch-attack.localdomain>
Denton Liu <liu.denton@gmail.com> writes:
> In these tests, there are many situations where
> 'echo "" | git mergetool' is used. This replaces all of those
> occurrences with 'git mergetool -y' for simplicity and readability.

"-y where _possible_" is not necessarily a good thing to do in tests. We do want to make sure that both "yes" from the input and "-y" from the command line work. Changes to "-y" done only for the tests that are not about accepting the interactive input from the end-user is a very good idea, but "replaces all of those" makes me worried.

Show 8 quoted lines
> -	( yes "" | git mergetool both >/dev/null 2>&1 ) &&
> -	( yes "" | git mergetool file1 file1 ) &&
> -	( yes "" | git mergetool file2 "spaced name" >/dev/null 2>&1 ) &&
> -	( yes "" | git mergetool subdir/file3 >/dev/null 2>&1 ) &&
> +	git mergetool -y both >/dev/null 2>&1 &&
> +	git mergetool -y file1 file1 &&
> +	git mergetool -y file2 "spaced name" >/dev/null 2>&1 &&
> +	git mergetool -y subdir/file3 >/dev/null 2>&1 &&

So these replace "the user interactively keeps typing <ENTER>" with "-y", which sounds good. These are obviously more about what the code actually does.

Show 10 quoted lines
> -	( yes "" | git mergetool file1 >/dev/null 2>&1 ) &&
> -	( yes "" | git mergetool file2 >/dev/null 2>&1 ) &&
> -	( yes "" | git mergetool "spaced name" >/dev/null 2>&1 ) &&
> -	( yes "" | git mergetool both >/dev/null 2>&1 ) &&
> -	( yes "" | git mergetool subdir/file3 >/dev/null 2>&1 ) &&
> +	git mergetool file1 >/dev/null 2>&1 &&
> +	git mergetool file2 >/dev/null 2>&1 &&
> +	git mergetool "spaced name" >/dev/null 2>&1 &&
> +	git mergetool both >/dev/null 2>&1 &&
> +	git mergetool subdir/file3 >/dev/null 2>&1 &&

The reason for the lack of "-y" in the rewrite, in contrast to what was done in the previous hunk we saw, is not quite obvious.

Show 6 quoted lines
> @@ -177,7 +177,7 @@ test_expect_success 'mergetool in subdir' '
>  	(
>  		cd subdir &&
>  		test_expect_code 1 git merge master >/dev/null 2>&1 &&
> -		( yes "" | git mergetool file3 >/dev/null 2>&1 ) &&
> +		git mergetool file3 >/dev/null 2>&1 &&

Likewise, and likewise for the remainder of the patch where the updated command line does not say "-y".

Previous: Denton LiuNext: Denton Liu
Message 2 of 3 in “Use -y where possible in test t7610-mergetool”
  1. 2/5 Use -y where possible in test t7610-mergetoolDenton Liu, Mar 3, 2017
  2. Junio C HamanoMar 3, 2017
  3. Denton LiuMar 3, 2017

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.