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

Re: [PATCH] t3404: fix use of "VAR=VAL cmd" with a shell function

From
Junio C Hamano <gitster@pobox.com>
Date
Jul 12, 2018, 20:22 UTC
Message-ID
<xmqq4lh4w6e8.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<20180712201454.GA6281@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
Show 36 quoted lines
> On Thu, Jul 12, 2018 at 01:07:51PM -0700, Junio C Hamano wrote:
>
>> Bash may take it happily but running test with dash reveals a breakage.
>> 
>> This was not discovered for a long time as no tests after this test
>> depended on GIT_AUTHOR_NAME to be reverted correctly back to the
>> original value after this step is done.
>> 
>> Signed-off-by: Junio C Hamano <gitster@pobox.com>
>> ---
>> 
>>  * We could enclose the setting and exporting inside a subshell and
>>    do without the oGIT_AUTHOR_NAME temporary variable, but that
>>    would interfere with the timestamp increments done by
>>    test_commit, so I think doing it this way may be preferrable.
>
> Yeah, I agree that setting/unsetting is probably more sane for this
> case. Though...
>
>> diff --git a/t/t3404-rebase-interactive.sh b/t/t3404-rebase-interactive.sh
>> index 7e9f375a24..fd43443ff5 100755
>> --- a/t/t3404-rebase-interactive.sh
>> +++ b/t/t3404-rebase-interactive.sh
>> @@ -280,8 +280,11 @@ test_expect_success 'retain authorship w/ conflicts' '
>>  	git reset --hard twerp &&
>>  	test_commit a conflict a conflict-a &&
>>  	git reset --hard twerp &&
>> -	GIT_AUTHOR_NAME=AttributeMe \
>> +	oGIT_AUTHOR_NAME=$GIT_AUTHOR_NAME &&
>> +	GIT_AUTHOR_NAME=AttributeMe &&
>> +	export GIT_AUTHOR_NAME &&
>>  	test_commit b conflict b conflict-b &&
>> +	GIT_AUTHOR_NAME=$oGIT_AUTHOR_NAME &&
>
> ...would you want to use test_when_finished here (both for robustness,
> but also to make it more clear to a reader what's going on)?
Perhaps.

I wish our test-lint caught "VAR=VAL shellfunc", but it is rather hard to do so, I would imagine.

Previous: Jeff KingNext: Junio C Hamano
Message 3 of 6 in “t3404: fix use of "VAR=VAL cmd" with a shell function”
  1. t3404: fix use of "VAR=VAL cmd" with a shell functionJunio C Hamano, Jul 12, 2018
  2. Jeff KingJul 12, 2018
  3. Junio C HamanoJul 12, 2018
  4. Junio C HamanoJul 12, 2018
  5. Jeff KingJul 12, 2018
  6. Eric SunshineJul 13, 2018

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.