From: Derrick Stolee <derrickstolee@github.com>
To: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>,
"Derrick Stolee via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 4/5] config: return an empty list, not NULL
Date: Tue, 27 Sep 2022 12:50:37 -0400 [thread overview]
Message-ID: <b85d8a43-6640-aa9c-3103-0c3d43c2a479@github.com> (raw)
In-Reply-To: <220927.86sfkcyebf.gmgdl@evledraar.gmail.com>
On 9/27/2022 12:21 PM, Ævar Arnfjörð Bjarmason wrote:
>
> On Tue, Sep 27 2022, Derrick Stolee via GitGitGadget wrote:
>> /**
>> * Finds and returns the value list, sorted in order of increasing priority
>> * for the configuration variable `key`. When the configuration variable
>> - * `key` is not found, returns NULL. The caller should not free or modify
>> - * the returned pointer, as it is owned by the cache.
>> + * `key` is not found, returns an empty list. The caller should not free or
>> + * modify the returned pointer, as it is owned by the cache.
>> */
>> const struct string_list *git_config_get_value_multi(const char *key);
>
> Aside from the "DWIM API" aspect of this (which I don't mind) I think
> this is really taking the low-level function in the wrong direction, and
> that we should just add a new simple wrapper instead.
>
> I.e. both the pre-image API docs & this series gloss over the fact that
> we'd not just return NULL here if the config wasn't there, but also if
> git_config_parse_key() failed.
>
> So it seems to me that a better direction would be starting with
> something like the WIP below (which doesn't compile the whole code, I
> stopped at config.[ch] and pack-bitmap.c). I.e. the same "int" return
> and "dest" pattern that most other things in the config API have.
Do you have an example where a caller would benefit from this
distinction? Without such an example, I don't think it is worth
creating such a huge change for purity's sake alone.
I'm pretty happy that the diff for this series is an overall
reduction in code, while also not being too large in the interim:
12 files changed, 39 insertions(+), 57 deletions(-)
If all callers that use the *_multi() methods would only use the
wrapper, then what is the point of doing the low-level manipulations?
Thanks,
-Stolee
next prev parent reply other threads:[~2022-09-27 16:52 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-27 14:08 [PATCH 0/5] [RFC] config API: return empty list, not NULL Derrick Stolee via GitGitGadget
2022-09-27 14:08 ` [PATCH 1/5] config: relax requirements on multi-value return Derrick Stolee via GitGitGadget
2022-09-27 17:26 ` Junio C Hamano
2022-09-27 14:08 ` [PATCH 2/5] *: relax git_configset_get_value_multi result Derrick Stolee via GitGitGadget
2022-09-28 15:58 ` Taylor Blau
2022-09-27 14:08 ` [PATCH 3/5] config: add BUG() statement instead of possible segfault Derrick Stolee via GitGitGadget
2022-09-27 16:17 ` Ævar Arnfjörð Bjarmason
2022-09-27 16:46 ` Derrick Stolee
2022-09-27 17:22 ` Ævar Arnfjörð Bjarmason
2022-09-27 14:08 ` [PATCH 4/5] config: return an empty list, not NULL Derrick Stolee via GitGitGadget
2022-09-27 16:21 ` Ævar Arnfjörð Bjarmason
2022-09-27 16:50 ` Derrick Stolee [this message]
2022-09-27 19:18 ` Ævar Arnfjörð Bjarmason
2022-09-28 13:46 ` Derrick Stolee
2022-09-28 14:37 ` Ævar Arnfjörð Bjarmason
2022-09-28 18:10 ` Derrick Stolee
2022-09-28 19:33 ` Ævar Arnfjörð Bjarmason
2022-09-27 14:08 ` [PATCH 5/5] *: expect a non-NULL list of config values Derrick Stolee via GitGitGadget
2022-09-28 2:40 ` [PATCH 0/5] [RFC] config API: return empty list, not NULL Junio C Hamano
2022-09-28 18:38 ` Derrick Stolee
2022-09-28 19:27 ` Ævar Arnfjörð Bjarmason
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=b85d8a43-6640-aa9c-3103-0c3d43c2a479@github.com \
--to=derrickstolee@github.com \
--cc=avarab@gmail.com \
--cc=git@vger.kernel.org \
--cc=gitgitgadget@gmail.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).