Web lists-archives.com

Re: [Patch v2] t2027: avoid using pipes

Prathamesh Chavan <pc44800@xxxxxxxxx> writes:

> From: Prathamesh <pc44800@xxxxxxxxx>

Your e-mail header says 

	From: Prathamesh Chavan <pc44800@xxxxxxxxx>

and you probably have "[user] name = Prathamesh" somewhere in your
config, and I think that is why we see the above line in format-patch
output and on your sign-off.  If you really prefer to be known as a
person with a single name (without Chavan) to the community, that is
fine, but if that is not the case, perhaps you'd want to review your
config and fix this.

> Whenever a git command is present in the upstream of a pipe, its failure
> gets masked by piping and hence it should be avoided for testing the
> upstream git command. By writing out the output of the git command to
> a file, we can test the exit codes of both the commands as a failure exit
> code in any command is able to stop the && chain.


> Signed-off-by: Prathamesh <pc44800@xxxxxxxxx>

> diff --git a/t/t2027-worktree-list.sh b/t/t2027-worktree-list.sh
> index 848da5f36..a3e77fee5 100755
> --- a/t/t2027-worktree-list.sh
> +++ b/t/t2027-worktree-list.sh
> @@ -31,7 +31,8 @@ test_expect_success '"list" all worktrees from main' '
>  	test_when_finished "rm -rf here && git worktree prune" &&
>  	git worktree add --detach here master &&
>  	echo "$(git -C here rev-parse --show-toplevel) $(git rev-parse --short HEAD) (detached HEAD)" >>expect &&
> -	git worktree list | sed "s/  */ /g" >actual &&
> +	git worktree list >out &&
> +	sed "s/  */ /g" <out >actual &&
>  	test_cmp expect actual
>  '

We'll have "out" as a new leftover file, but it probably would not
make too much of a difference.  We already leave 'expect' and 'actual'
in the working tree as known crufts.  

Just FYI, if you want to clean them, there is already when_finished
in this piece (and others) so you could do

    -test_when_finished "rm -rf here && git worktree prune" &&
    -test_when_finished "rm -rf here out actual expect && git worktree prune" &&

When a test fails, when_finished is not run, so this will not
interfere with necessary debugging effort when/if somebody breaks
"git worktree" and this test starts failing.