From: Junio C Hamano <gitster@pobox.com>
To: Karthik Nayak <karthik.188@gmail.com>
Cc: Kenneth Lorber <keni@his.com>,
git@vger.kernel.org, Patrick Steinhardt <ps@pks.im>
Subject: Re: [RFC PATCH 1/1] config: surface editor failure in exit code
Date: Wed, 19 Aug 2026 13:11:09 -0700 [thread overview]
Message-ID: <xmqqy0e1uazm.fsf@gitster.g> (raw)
In-Reply-To: <CAOLa=ZQLgxhq2TVS1AYpRoAc_8AkWVtv_VhEm2HovgEX_cFvWg@mail.gmail.com> (Karthik Nayak's message of "Tue, 18 Aug 2026 04:42:59 -0400")
Karthik Nayak <karthik.188@gmail.com> writes:
>> +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.
>> +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.
next prev parent reply other threads:[~2026-08-19 20:11 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-17 21:19 [RFC PATCH 0/1] config: surface editor failure in exit code Kenneth Lorber
2026-08-17 21:19 ` [RFC PATCH 1/1] " Kenneth Lorber
2026-08-18 8:42 ` Karthik Nayak
2026-08-19 11:17 ` Kenneth Lorber
2026-08-19 20:11 ` Junio C Hamano [this message]
2026-08-17 22:39 ` [RFC PATCH 0/1] " Junio C Hamano
2026-08-18 8:26 ` Karthik Nayak
2026-08-18 14:31 ` Junio C Hamano
2026-08-18 22:12 ` brian m. carlson
2026-08-19 15:09 ` [PATCH v2 " Kenneth Lorber
2026-08-19 15:09 ` [PATCH v2 1/1] " Kenneth Lorber
2026-08-19 15:09 ` [PATCH v2 0/1] " Kenneth Lorber
2026-08-19 15:09 ` [PATCH v2 1/1] " Kenneth Lorber
2026-08-19 17:58 ` [PATCH v2 0/1] " Junio C Hamano
2026-08-19 18:58 ` Kenneth Lorber
2026-08-19 19:24 ` Junio C Hamano
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=xmqqy0e1uazm.fsf@gitster.g \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=karthik.188@gmail.com \
--cc=keni@his.com \
--cc=ps@pks.im \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.