diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2018-05-26 15:55:21 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-05-29 07:51:28 +0200 |
commit | a73b3680c4910866e3e215c3927a0c71f0b9229d (patch) | |
tree | 4c48aca0f71bba28888b19f3dec47088334ea7d1 /config.h | |
parent | Merge branch 'nd/command-list' into nd/complete-config-vars (diff) | |
download | git-a73b3680c4910866e3e215c3927a0c71f0b9229d.tar.xz git-a73b3680c4910866e3e215c3927a0c71f0b9229d.zip |
Add and use generic name->id mapping code for color slot parsing
Instead of hard coding the name-to-id mapping in C code, keep it in an
array and use a common function to do the parsing. This reduces code
and also allows us to list all possible color slots later.
This starts using C99 designated initializers more for convenience
(the first designated initializers have been introduced in builtin/clean.c
for some time without complaints)
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'config.h')
-rw-r--r-- | config.h | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -257,4 +257,8 @@ struct key_value_info { extern NORETURN void git_die_config(const char *key, const char *err, ...) __attribute__((format(printf, 2, 3))); extern NORETURN void git_die_config_linenr(const char *key, const char *filename, int linenr); +#define LOOKUP_CONFIG(mapping, var) \ + lookup_config(mapping, ARRAY_SIZE(mapping), var) +int lookup_config(const char **mapping, int nr_mapping, const char *var); + #endif /* CONFIG_H */ |