]> git.ipfire.org Git - thirdparty/git.git/commitdiff
urlmatch.[ch]: add and use URLMATCH_CONFIG_INIT
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Fri, 1 Oct 2021 10:27:33 +0000 (12:27 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 1 Oct 2021 21:22:51 +0000 (14:22 -0700)
Change the initialization pattern of "struct urlmatch_config" to use
an *_INIT macro and designated initializers. Right now there's no
other "struct" member of "struct urlmatch_config" which would require
its own *_INIT, but it's good practice not to assume that. Let's also
change this to a designated initializer while we're at it.

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/config.c
credential.c
http.c
urlmatch.h

index 865fddd6ce8535522e540c3302c60c1ec19737a7..542d8d02b2b00a8675d6bff9245019d0251d043f 100644 (file)
@@ -575,7 +575,7 @@ static int get_urlmatch(const char *var, const char *url)
        int ret;
        char *section_tail;
        struct string_list_item *item;
-       struct urlmatch_config config = { STRING_LIST_INIT_DUP };
+       struct urlmatch_config config = URLMATCH_CONFIG_INIT;
        struct string_list values = STRING_LIST_INIT_DUP;
 
        config.collect_fn = urlmatch_collect_fn;
index 000ac7a8d430e4d14472c068b9817e1fc8ee69bd..e7240f3f636f9d687836b7fe6df65b548ce285fd 100644 (file)
@@ -105,7 +105,7 @@ static int match_partial_url(const char *url, void *cb)
 static void credential_apply_config(struct credential *c)
 {
        char *normalized_url;
-       struct urlmatch_config config = { STRING_LIST_INIT_DUP };
+       struct urlmatch_config config = URLMATCH_CONFIG_INIT;
        struct strbuf url = STRBUF_INIT;
 
        if (!c->host)
diff --git a/http.c b/http.c
index d7c20493d7f3c58dc7a71bb75dd9f7f10d86ebdc..da12471c242eb9866baac234b029d11d4fb2e842 100644 (file)
--- a/http.c
+++ b/http.c
@@ -990,7 +990,7 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)
        char *low_speed_limit;
        char *low_speed_time;
        char *normalized_url;
-       struct urlmatch_config config = { STRING_LIST_INIT_DUP };
+       struct urlmatch_config config = URLMATCH_CONFIG_INIT;
 
        config.section = "http";
        config.key = NULL;
index 6ff42f81b0c1e0fdcdd75511f8b7746da0dccbf7..34a3ba6d1973b4aa8d82a2af7fab8b6672433cc5 100644 (file)
@@ -66,6 +66,10 @@ struct urlmatch_config {
        int (*fallback_match_fn)(const char *url, void *cb);
 };
 
+#define URLMATCH_CONFIG_INIT { \
+       .vars = STRING_LIST_INIT_DUP, \
+}
+
 int urlmatch_config_entry(const char *var, const char *value, void *cb);
 
 #endif /* URL_MATCH_H */