Use `git_config_get_value()` 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 <tanay...@gmail.com>
---
 notes.c | 21 +++++++--------------
 1 file changed, 7 insertions(+), 14 deletions(-)

diff --git a/notes.c b/notes.c
index 5fe691d..20c20f5 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,6 +1028,7 @@ struct notes_tree **load_notes_trees(struct string_list 
*refs)
 void init_display_notes(struct display_notes_opt *opt)
 {
        char *display_ref_env;
+       const char *value = NULL;
        int load_config_refs = 0;
        display_notes_refs.strdup_strings = 1;
 
@@ -1058,7 +1046,12 @@ 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 && !git_config_get_value("notes.displayref", 
&value)) {
+               if (!value)
+                       config_error_nonbool("notes.displayref");
+               else
+                       string_list_add_refs_by_glob(&display_notes_refs, 
value);
+       }
 
        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 majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to