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