Subject: Re: [PATCH v2 11/27] blame tests: simplify userdiff driver test

From: Junio C Hamano <[email-masked]>
Date: Tue, 16 Feb 2021 17:40:16 -0800

Ævar Arnfjörð Bjarmason <[email-masked]> writes:

>>> +	fortran_file=file.f03 &&
>>> +	test_when_finished "rm .gitattributes" &&
>>> +	echo "$fortran_file diff=fortran" >.gitattributes &&
>>> +
>>> +	test_commit --author "A <[email-masked]>" \
>>> +		"add" $fortran_file \
>>> +		"$(cat file.template)" &&
>>> +	test_commit --author "B <[email-masked]>" \
>>> +		"change" $fortran_file \
>>> +		"$(cat file.template | sed -e s/ChangeMe/IWasChanged/)" &&
>>> +	check_count -f $fortran_file -L:RIGHT A 3 B 1
> ...
>> Please place "$fortran_file" in dquotes on the check_count line.
>
> Why do we need to dquote a convenience variable defined in the test
> itself that'll never contain spaces or other funny things we'd get if we
> had $(pwd) or whatever in there? It wouldn't hurt, but maybe I'm missing
> some reason for why it's necessary or desired here.

Always dquoting when the code does not depend on splitting at IFS
whitespace reduces cognitive load.  The person who looks at the
variable reference, $fortran_file, has to wonder if the unquoted
form is used to take advantage of being split at IFS whitespaces, or
the test author saved two keystrokes because the filename does not
have any such whitespace, and go back to the assignment to check.