diff mbox series

[1/6] t1600-index: remove unnecessary redirection

Message ID 20210817174938.3009923-2-szeder.dev@gmail.com (mailing list archive)
State Superseded
Headers show
Series Fix GIT_TEST_SPLIT_INDEX | expand

Commit Message

SZEDER Gábor Aug. 17, 2021, 5:49 p.m. UTC
In a helper function in the 't1600-index.sh' test script the stderr
of a 'git add' command is redirected to its stdout, but its stdout is
not redirected anywhere.  So apparently this redirection is
unnecessary, remove it.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
---
 t/t1600-index.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Derrick Stolee Aug. 17, 2021, 6:12 p.m. UTC | #1
On 8/17/2021 1:49 PM, SZEDER Gábor wrote:
> In a helper function in the 't1600-index.sh' test script the stderr
> of a 'git add' command is redirected to its stdout, but its stdout is
> not redirected anywhere.  So apparently this redirection is
> unnecessary, remove it.
> 
> Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
> ---
>  t/t1600-index.sh | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/t/t1600-index.sh b/t/t1600-index.sh
> index c9b9e718b8..5d10cec67a 100755
> --- a/t/t1600-index.sh
> +++ b/t/t1600-index.sh
> @@ -79,7 +79,7 @@ test_index_version () {
>  		else
>  			unset GIT_INDEX_VERSION
>  		fi &&
> -		git add a 2>&1 &&
> +		git add a &&
>  		echo $EXPECTED_OUTPUT_VERSION >expect &&
>  		test-tool index-version <.git/index >actual &&
>  		test_cmp expect actual

Since here we have a 'test_cmp expect actual', perhaps the
actual mistake is that the line isn't

	git add a 2>&1 >actual &&

What do you think about that?

Thanks,
-Stolee
SZEDER Gábor Aug. 17, 2021, 6:39 p.m. UTC | #2
On Tue, Aug 17, 2021 at 02:12:36PM -0400, Derrick Stolee wrote:
> On 8/17/2021 1:49 PM, SZEDER Gábor wrote:
> > In a helper function in the 't1600-index.sh' test script the stderr
> > of a 'git add' command is redirected to its stdout, but its stdout is
> > not redirected anywhere.  So apparently this redirection is
> > unnecessary, remove it.
> > 
> > Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
> > ---
> >  t/t1600-index.sh | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/t/t1600-index.sh b/t/t1600-index.sh
> > index c9b9e718b8..5d10cec67a 100755
> > --- a/t/t1600-index.sh
> > +++ b/t/t1600-index.sh
> > @@ -79,7 +79,7 @@ test_index_version () {
> >  		else
> >  			unset GIT_INDEX_VERSION
> >  		fi &&
> > -		git add a 2>&1 &&
> > +		git add a &&
> >  		echo $EXPECTED_OUTPUT_VERSION >expect &&
> >  		test-tool index-version <.git/index >actual &&
> >  		test_cmp expect actual
> 
> Since here we have a 'test_cmp expect actual', perhaps the
> actual mistake is that the line isn't
> 
> 	git add a 2>&1 >actual &&
> 
> What do you think about that?

The actual file is written two lines later as:

  test-tool index-version <.git/index >actual

So it seems that neither stdout nor stderr of that 'git add' command
matters.

However, in most of the preceeding tests 'git add's stderr does indeed
matter, as they do:

    git add a 2>&1 | sed "s/[0-9]//" >actual.err &&
    # write expect.err
    test_cmp expect.err actual.err

I suspect that the 2>&1 redirection this patch is removing might have
been a copy-paste error.
Derrick Stolee Aug. 17, 2021, 6:48 p.m. UTC | #3
On 8/17/2021 2:39 PM, SZEDER Gábor wrote:
> On Tue, Aug 17, 2021 at 02:12:36PM -0400, Derrick Stolee wrote:
>> On 8/17/2021 1:49 PM, SZEDER Gábor wrote:
>>> In a helper function in the 't1600-index.sh' test script the stderr
>>> of a 'git add' command is redirected to its stdout, but its stdout is
>>> not redirected anywhere.  So apparently this redirection is
>>> unnecessary, remove it.
>>>
>>> Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
>>> ---
>>>  t/t1600-index.sh | 2 +-
>>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>>
>>> diff --git a/t/t1600-index.sh b/t/t1600-index.sh
>>> index c9b9e718b8..5d10cec67a 100755
>>> --- a/t/t1600-index.sh
>>> +++ b/t/t1600-index.sh
>>> @@ -79,7 +79,7 @@ test_index_version () {
>>>  		else
>>>  			unset GIT_INDEX_VERSION
>>>  		fi &&
>>> -		git add a 2>&1 &&
>>> +		git add a &&
>>>  		echo $EXPECTED_OUTPUT_VERSION >expect &&
>>>  		test-tool index-version <.git/index >actual &&
>>>  		test_cmp expect actual
>>
>> Since here we have a 'test_cmp expect actual', perhaps the
>> actual mistake is that the line isn't
>>
>> 	git add a 2>&1 >actual &&
>>
>> What do you think about that?
> 
> The actual file is written two lines later as:
> 
>   test-tool index-version <.git/index >actual
> 
> So it seems that neither stdout nor stderr of that 'git add' command
> matters.

Of course. Sorry for misreading.

> However, in most of the preceeding tests 'git add's stderr does indeed
> matter, as they do:
> 
>     git add a 2>&1 | sed "s/[0-9]//" >actual.err &&
>     # write expect.err
>     test_cmp expect.err actual.err
> 
> I suspect that the 2>&1 redirection this patch is removing might have
> been a copy-paste error.

That makes more sense than an errant addition.

Thanks,
-Stolee
diff mbox series

Patch

diff --git a/t/t1600-index.sh b/t/t1600-index.sh
index c9b9e718b8..5d10cec67a 100755
--- a/t/t1600-index.sh
+++ b/t/t1600-index.sh
@@ -79,7 +79,7 @@  test_index_version () {
 		else
 			unset GIT_INDEX_VERSION
 		fi &&
-		git add a 2>&1 &&
+		git add a &&
 		echo $EXPECTED_OUTPUT_VERSION >expect &&
 		test-tool index-version <.git/index >actual &&
 		test_cmp expect actual