Use `git_config_get_value_multi()` instead of `git_config()` to take advantage of the config-set API which provides a cleaner control flow, also previously 'string_list_add_refs_by_glob()' was called even when the retrieved value was NULL, correct it while we are at it. Signed-off-by: Tanay Abhra <tanayabh@xxxxxxxxx> --- notes.c | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/notes.c b/notes.c index 5fe691d..abb0ce0 100644 --- a/notes.c +++ b/notes.c @@ -961,19 +961,6 @@ void string_list_add_refs_from_colon_sep(struct string_list *list, free(globs_copy); } -static int notes_display_config(const char *k, const char *v, void *cb) -{ - int *load_refs = cb; - - if (*load_refs && !strcmp(k, "notes.displayref")) { - if (!v) - config_error_nonbool(k); - string_list_add_refs_by_glob(&display_notes_refs, v); - } - - return 0; -} - const char *default_notes_ref(void) { const char *notes_ref = NULL; @@ -1041,7 +1028,8 @@ struct notes_tree **load_notes_trees(struct string_list *refs) void init_display_notes(struct display_notes_opt *opt) { char *display_ref_env; - int load_config_refs = 0; + const struct string_list *values; + int load_config_refs = 0, i; display_notes_refs.strdup_strings = 1; assert(!display_notes_trees); @@ -1058,7 +1046,18 @@ void init_display_notes(struct display_notes_opt *opt) load_config_refs = 1; } - git_config(notes_display_config, &load_config_refs); + if (load_config_refs) { + values = git_config_get_value_multi("notes.displayref"); + if (values) { + for (i = 0; i < values->nr; i++) { + if (!values->items[i].string) + config_error_nonbool("notes.displayref"); + else + string_list_add_refs_by_glob(&display_notes_refs, + values->items[i].string); + } + } + } if (opt) { struct string_list_item *item; -- 1.9.0.GIT -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html