diff options
author | Ævar Arnfjörð Bjarmason <avarab@gmail.com> | 2021-10-01 12:27:34 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-10-01 14:22:51 -0700 |
commit | 0bc7787ca9ea123e28769f728d77261cad1f1557 (patch) | |
tree | ed0b7ed15f9912a7a1bb9d0ec6fa47922f17550e /help.h | |
parent | urlmatch.[ch]: add and use URLMATCH_CONFIG_INIT (diff) | |
download | tgif-0bc7787ca9ea123e28769f728d77261cad1f1557.tar.xz |
builtin/remote.c: add and use a REF_STATES_INIT
Use a new REF_STATES_INIT designated initializer instead of assigning
to the "strdup_strings" member of the previously memzero()'d version
of this struct.
The pattern of assigning to "strdup_strings" dates back to
211c89682ee (Make git-remote a builtin, 2008-02-29) (when it was
"strdup_paths"), i.e. long before we used anything like our current
established *_INIT patterns consistently.
Then in e61e0cc6b70 (builtin-remote: teach show to display remote
HEAD, 2009-02-25) and e5dcbfd9ab7 (builtin-remote: new show output
style for push refspecs, 2009-02-25) we added some more of these.
As it turns out we only initialized this struct three times, all the
other uses were of pointers to those initialized structs. So let's
initialize it in those three places, skip the memset(), and pass those
structs down appropriately.
This would be a behavior change if we had codepaths that relied say on
implicitly having had "new_refs" initialized to STRING_LIST_INIT_NODUP
with the memset(), but only set the "strdup_strings" on some other
struct, but then called string_list_append() on "new_refs". There
isn't any such codepath, all of the late assignments to
"strdup_strings" assigned to those structs that we'd use for those
codepaths.
So just initializing them all up-front makes for easier to understand
code, i.e. in the pre-image it looked as though we had that tricky
edge case, but we didn't.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'help.h')
0 files changed, 0 insertions, 0 deletions