]> git.ipfire.org Git - thirdparty/git.git/commit
builtin/receive-pack.c: remove redundant 'if'
authorTaylor Blau <me@ttaylorr.com>
Wed, 18 May 2022 20:26:02 +0000 (16:26 -0400)
committerJunio C Hamano <gitster@pobox.com>
Wed, 18 May 2022 20:58:39 +0000 (13:58 -0700)
commitaf845a604da3b9aec2e4ef69d3318962d46322b6
tree3606a813935f44685f96731b801599d3d146dc31
parentd516b2db0af2221bd6b13e7347abdcb5830b2829
builtin/receive-pack.c: remove redundant 'if'

In c7c4bdeccf (run-command API: remove "env" member, always use
"env_array", 2021-11-25), there was a push to replace

    cld.env = env->v;

with

    strvec_pushv(&cld.env_array, env->v);

The conversion in c7c4bdeccf was mostly plug-and-play, with the snag
that some instances of strvec_pushv() became guarded with a NULL check
to ensure that the second argument was non-NULL.

This conversion was slightly over-eager to add a conditional in
builtin/receive-pack.c::unpack(), since we know at the point that we
add the result of `tmp_objdir_env()` into the child process's
environment, that `tmp_objdir` is non-NULL.

This follows from the conditional just before our strvec_pushv() call
(which returns from the function if `tmp_objdir` was NULL), as well as
the call to tmp_objdir_add_as_alternate() just below, which relies on
its argument (`tmp_objdir`) being non-NULL.

In the meantime, this extra conditional isn't hurting anything. But it
is redundant and thus unnecessarily confusing. So let's remove it.

Signed-off-by: Taylor Blau <me@ttaylorr.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/receive-pack.c