Skip to content

Commit 73ee449

Browse files
avargitster
authored andcommitted
urlmatch.[ch]: add and use URLMATCH_CONFIG_INIT
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>
1 parent 4eb2bfd commit 73ee449

File tree

4 files changed

+7
-3
lines changed

4 files changed

+7
-3
lines changed

builtin/config.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ static int get_urlmatch(const char *var, const char *url)
575575
int ret;
576576
char *section_tail;
577577
struct string_list_item *item;
578-
struct urlmatch_config config = { STRING_LIST_INIT_DUP };
578+
struct urlmatch_config config = URLMATCH_CONFIG_INIT;
579579
struct string_list values = STRING_LIST_INIT_DUP;
580580

581581
config.collect_fn = urlmatch_collect_fn;

credential.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ static int match_partial_url(const char *url, void *cb)
105105
static void credential_apply_config(struct credential *c)
106106
{
107107
char *normalized_url;
108-
struct urlmatch_config config = { STRING_LIST_INIT_DUP };
108+
struct urlmatch_config config = URLMATCH_CONFIG_INIT;
109109
struct strbuf url = STRBUF_INIT;
110110

111111
if (!c->host)

http.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -990,7 +990,7 @@ void http_init(struct remote *remote, const char *url, int proactive_auth)
990990
char *low_speed_limit;
991991
char *low_speed_time;
992992
char *normalized_url;
993-
struct urlmatch_config config = { STRING_LIST_INIT_DUP };
993+
struct urlmatch_config config = URLMATCH_CONFIG_INIT;
994994

995995
config.section = "http";
996996
config.key = NULL;

urlmatch.h

+4
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ struct urlmatch_config {
6666
int (*fallback_match_fn)(const char *url, void *cb);
6767
};
6868

69+
#define URLMATCH_CONFIG_INIT { \
70+
.vars = STRING_LIST_INIT_DUP, \
71+
}
72+
6973
int urlmatch_config_entry(const char *var, const char *value, void *cb);
7074

7175
#endif /* URL_MATCH_H */

0 commit comments

Comments
 (0)