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

Re: [RFC PATCH 1/1] config: surface editor failure in exit code

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 19, 2026, 20:11 UTC
Message-ID
<xmqqy0e1uazm.fsf@gitster.g>
In-Reply-To
<CAOLa=ZQLgxhq2TVS1AYpRoAc_8AkWVtv_VhEm2HovgEX_cFvWg@mail.gmail.com>
Karthik Nayak <karthik.188@gmail.com> writes:
Show 11 quoted lines
>> +test_expect_success 'git config --edit successful exit' '
>> +	test_when_finished "rm -rf repo" &&
>> +	git init repo &&
>> +	GIT_EDITOR=true &&
>> +	export GIT_EDITOR &&
>> +	git -C repo config -e &&
>> +	unset GIT_EDITOR
>> +'
>
> Nit: couldn't this be simply `test_env GIT_EDITOR=true git -C repo
> config -e` and avoid the set, export and unset?
No, it should just be a single liner:
	GIT_EDITOR=true git -C repo config -e

I would recommend against use of test_env in most cases, because it introduces a subshell without making it obvious.

Show 10 quoted lines
>> +test_expect_success 'git config --edit failure exit' '
>> +	test_when_finished "rm -rf repo" &&
>> +	git init repo &&
>> +	GIT_EDITOR=false &&
>> +	export GIT_EDITOR &&
>> +	test_must_fail git -C repo config -e &&
>> +	unset GIT_EDITOR
>> +'
>
> Same here..

Even when you truly a need subshell, it is better to spell the subshell invocation out explicitly, i.e.,

    ...
    git init repo &&
    (
	GIT_EDITOR=false &&
	export GIT_EDITOR &&
	test_must_fail git -C repo config -e
    )
rather than using test_env.

But in a case like this where you do not even need a subshell to help you shield your actions from later steps, you can just use "env", like everybody else:

	test_must_fail env GIT_EDITOR=false git -C repo config -e
There are many uses of this pattern.
Thanks.
Previous: Kenneth LorberNext: Junio C Hamano
Message 5 of 16 in “config: surface editor failure in exit code”
  1. 0/1 config: surface editor failure in exit codeKenneth Lorber, Aug 17, 2026
  2. 1/1 config: surface editor failure in exit codeKenneth Lorber, Aug 17, 2026
  3. Karthik NayakAug 18, 2026
  4. Kenneth LorberAug 19, 2026
  5. Junio C HamanoAug 19, 2026
  6. Junio C HamanoAug 17, 2026
  7. Karthik NayakAug 18, 2026
  8. Junio C HamanoAug 18, 2026
  9. brian m. carlsonAug 18, 2026
  10. 0/1 config: surface editor failure in exit codeKenneth Lorber, Aug 19, 2026
  11. 1/1 config: surface editor failure in exit codeKenneth Lorber, Aug 19, 2026
  12. 0/1 config: surface editor failure in exit codeKenneth Lorber, Aug 19, 2026
  13. 1/1 config: surface editor failure in exit codeKenneth Lorber, Aug 19, 2026
  14. Junio C HamanoAug 19, 2026
  15. Kenneth LorberAug 19, 2026
  16. Junio C HamanoAug 19, 2026

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.