diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2018-05-26 15:55:25 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-05-29 14:51:28 +0900 |
commit | a4a9cc19a29df22f367fde50eec046ba6c5533f6 (patch) | |
tree | 885955f4bef244e683debcc62a4582c805a0e19a /fsck.c | |
parent | 3ac68a93fd2b984e2a7e570217d2646a208ffcc3 (diff) | |
download | git-a4a9cc19a29df22f367fde50eec046ba6c5533f6.tar.gz |
fsck: produce camelCase config key names
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 'fsck.c')
-rw-r--r-- | fsck.c | 22 |
1 files changed, 18 insertions, 4 deletions
@@ -74,14 +74,15 @@ enum fsck_msg_id { #undef MSG_ID #define STR(x) #x -#define MSG_ID(id, msg_type) { STR(id), NULL, FSCK_##msg_type }, +#define MSG_ID(id, msg_type) { STR(id), NULL, NULL, FSCK_##msg_type }, static struct { const char *id_string; const char *downcased; + const char *camelcased; int msg_type; } msg_id_info[FSCK_MSG_MAX + 1] = { FOREACH_MSG_ID(MSG_ID) - { NULL, NULL, -1 } + { NULL, NULL, NULL, -1 } }; #undef MSG_ID @@ -105,6 +106,20 @@ static void prepare_msg_ids(void) else *(q)++ = tolower(*(p)++); *q = '\0'; + + p = msg_id_info[i].id_string; + q = xmalloc(len); + msg_id_info[i].camelcased = q; + while (*p) { + if (*p == '_') { + p++; + if (*p) + *q++ = *p++; + } else { + *q++ = tolower(*p++); + } + } + *q = '\0'; } } @@ -127,9 +142,8 @@ void list_config_fsck_msg_ids(struct string_list *list, const char *prefix) prepare_msg_ids(); - /* TODO: we can do better by producing camelCase names */ for (i = 0; i < FSCK_MSG_MAX; i++) - list_config_item(list, prefix, msg_id_info[i].downcased); + list_config_item(list, prefix, msg_id_info[i].camelcased); } static int fsck_msg_type(enum fsck_msg_id msg_id, |