config.c: rename "struct config_source cf"
The "cf" name is a holdover from before 4d8dd1494e (config: make parsing stack struct independent from actual data source, 2013-07-12), when the struct was named config_file. Since that acronym no longer makes sense, rename "cf" to "cs". In some places, we have "struct config_set cs", so to avoid conflict, rename those "cs" to "set" ("config_set" would be more descriptive, but it's much longer and would require us to rewrap several lines). Signed-off-by: Glen Choo <chooglen@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Glen Choo committed
Mar 28, 2023 at 17:51 UTC
9b4a655302aae41a35752acfb61da1b43b4c7ce7
1 file changed
+131
-131
config.c
+131
-131
@@ -202,7 +202,7 @@ static const char include_depth_advice[] = N_(
202
"from\n"
203
" %s\n"
204
"This might be due to circular includes.");
205
-static int handle_path_include(struct config_source *cf, const char *path,
205
+static int handle_path_include(struct config_source *cs, const char *path,
206
struct config_include_data *inc)
207
{
208
int ret = 0;
@@ -224,14 +224,14 @@ static int handle_path_include(struct config_source *cf, const char *path,
224
if (!is_absolute_path(path)) {
225
char *slash;
226
227
- if (!cf || !cf->path) {
227
+ if (!cs || !cs->path) {
228
ret = error(_("relative config includes must come from files"));
229
goto cleanup;
230
}
231
232
- slash = find_last_dir_sep(cf->path);
232
+ slash = find_last_dir_sep(cs->path);
233
if (slash)
234
- strbuf_add(&buf, cf->path, slash - cf->path + 1);
234
+ strbuf_add(&buf, cs->path, slash - cs->path + 1);
235
strbuf_addstr(&buf, path);
236
path = buf.buf;
237
}
@@ -239,8 +239,8 @@ static int handle_path_include(struct config_source *cf, const char *path,
239
if (!access_or_die(path, R_OK, 0)) {
240
if (++inc->depth > MAX_INCLUDE_DEPTH)
241
die(_(include_depth_advice), MAX_INCLUDE_DEPTH, path,
242
- !cf ? "<unknown>" :
243
- cf->name ? cf->name :
242
+ !cs ? "<unknown>" :
243
+ cs->name ? cs->name :
244
"the command line");
245
ret = git_config_from_file(git_config_include, path, inc);
246
inc->depth--;
@@ -257,7 +257,7 @@ static void add_trailing_starstar_for_dir(struct strbuf *pat)
257
strbuf_addstr(pat, "**");
258
}
259
260
-static int prepare_include_condition_pattern(struct config_source *cf,
260
+static int prepare_include_condition_pattern(struct config_source *cs,
261
struct strbuf *pat)
262
{
263
struct strbuf path = STRBUF_INIT;
@@ -274,11 +274,11 @@ static int prepare_include_condition_pattern(struct config_source *cf,
274
if (pat->buf[0] == '.' && is_dir_sep(pat->buf[1])) {
275
const char *slash;
276
277
- if (!cf || !cf->path)
277
+ if (!cs || !cs->path)
278
return error(_("relative config include "
279
"conditionals must come from files"));
280
281
- strbuf_realpath(&path, cf->path, 1);
281
+ strbuf_realpath(&path, cs->path, 1);
282
slash = find_last_dir_sep(path.buf);
283
if (!slash)
284
BUG("how is this possible?");
@@ -293,7 +293,7 @@ static int prepare_include_condition_pattern(struct config_source *cf,
293
return prefix;
294
}
295
296
-static int include_by_gitdir(struct config_source *cf,
296
+static int include_by_gitdir(struct config_source *cs,
297
const struct config_options *opts,
298
const char *cond, size_t cond_len, int icase)
299
{
@@ -310,7 +310,7 @@ static int include_by_gitdir(struct config_source *cf,
310
311
strbuf_realpath(&text, git_dir, 1);
312
strbuf_add(&pattern, cond, cond_len);
313
- prefix = prepare_include_condition_pattern(cf, &pattern);
313
+ prefix = prepare_include_condition_pattern(cs, &pattern);
314
315
again:
316
if (prefix < 0)
@@ -449,16 +449,16 @@ static int include_by_remote_url(struct config_include_data *inc,
449
inc->remote_urls);
450
}
451
452
-static int include_condition_is_true(struct config_source *cf,
452
+static int include_condition_is_true(struct config_source *cs,
453
struct config_include_data *inc,
454
const char *cond, size_t cond_len)
455
{
456
const struct config_options *opts = inc->opts;
457
458
if (skip_prefix_mem(cond, cond_len, "gitdir:", &cond, &cond_len))
459
- return include_by_gitdir(cf, opts, cond, cond_len, 0);
459
+ return include_by_gitdir(cs, opts, cond, cond_len, 0);
460
else if (skip_prefix_mem(cond, cond_len, "gitdir/i:", &cond, &cond_len))
461
- return include_by_gitdir(cf, opts, cond, cond_len, 1);
461
+ return include_by_gitdir(cs, opts, cond, cond_len, 1);
462
else if (skip_prefix_mem(cond, cond_len, "onbranch:", &cond, &cond_len))
463
return include_by_branch(cond, cond_len);
464
else if (skip_prefix_mem(cond, cond_len, "hasconfig:remote.*.url:", &cond,
@@ -472,7 +472,7 @@ static int include_condition_is_true(struct config_source *cf,
472
static int git_config_include(const char *var, const char *value, void *data)
473
{
474
struct config_include_data *inc = data;
475
- struct config_source *cf = inc->config_reader->source;
475
+ struct config_source *cs = inc->config_reader->source;
476
const char *cond, *key;
477
size_t cond_len;
478
int ret;
@@ -486,16 +486,16 @@ static int git_config_include(const char *var, const char *value, void *data)
486
return ret;
487
488
if (!strcmp(var, "include.path"))
489
- ret = handle_path_include(cf, value, inc);
489
+ ret = handle_path_include(cs, value, inc);
490
491
if (!parse_config_key(var, "includeif", &cond, &cond_len, &key) &&
492
- cond && include_condition_is_true(cf, inc, cond, cond_len) &&
492
+ cond && include_condition_is_true(cs, inc, cond, cond_len) &&
493
!strcmp(key, "path")) {
494
config_fn_t old_fn = inc->fn;
495
496
if (inc->opts->unconditional_remote_url)
497
inc->fn = forbid_remote_url;
498
- ret = handle_path_include(cf, value, inc);
498
+ ret = handle_path_include(cs, value, inc);
499
inc->fn = old_fn;
500
}
501
@@ -820,21 +820,21 @@ out:
820
return ret;
821
}
822
823
-static int get_next_char(struct config_source *cf)
823
+static int get_next_char(struct config_source *cs)
824
{
825
- int c = cf->do_fgetc(cf);
825
+ int c = cs->do_fgetc(cs);
826
827
if (c == '\r') {
828
/* DOS like systems */
829
- c = cf->do_fgetc(cf);
829
+ c = cs->do_fgetc(cs);
830
if (c != '\n') {
831
if (c != EOF)
832
- cf->do_ungetc(c, cf);
832
+ cs->do_ungetc(c, cs);
833
c = '\r';
834
}
835
}
836
837
- if (c != EOF && ++cf->total_len > INT_MAX) {
837
+ if (c != EOF && ++cs->total_len > INT_MAX) {
838
/*
839
* This is an absurdly long config file; refuse to parse
840
* further in order to protect downstream code from integer
@@ -842,38 +842,38 @@ static int get_next_char(struct config_source *cf)
842
* but we can mark EOF and put trash in the return value,
843
* which will trigger a parse error.
844
*/
845
- cf->eof = 1;
845
+ cs->eof = 1;
846
return 0;
847
}
848
849
if (c == '\n')
850
- cf->linenr++;
850
+ cs->linenr++;
851
if (c == EOF) {
852
- cf->eof = 1;
853
- cf->linenr++;
852
+ cs->eof = 1;
853
+ cs->linenr++;
854
c = '\n';
855
}
856
return c;
857
}
858
859
-static char *parse_value(struct config_source *cf)
859
+static char *parse_value(struct config_source *cs)
860
{
861
int quote = 0, comment = 0, space = 0;
862
863
- strbuf_reset(&cf->value);
863
+ strbuf_reset(&cs->value);
864
for (;;) {
865
- int c = get_next_char(cf);
865
+ int c = get_next_char(cs);
866
if (c == '\n') {
867
if (quote) {
868
- cf->linenr--;
868
+ cs->linenr--;
869
return NULL;
870
}
871
- return cf->value.buf;
871
+ return cs->value.buf;
872
}
873
if (comment)
874
continue;
875
if (isspace(c) && !quote) {
876
- if (cf->value.len)
876
+ if (cs->value.len)
877
space++;
878
continue;
879
}
@@ -884,9 +884,9 @@ static char *parse_value(struct config_source *cf)
884
}
885
}
886
for (; space; space--)
887
- strbuf_addch(&cf->value, ' ');
887
+ strbuf_addch(&cs->value, ' ');
888
if (c == '\\') {
889
- c = get_next_char(cf);
889
+ c = get_next_char(cs);
890
switch (c) {
891
case '\n':
892
continue;
@@ -906,18 +906,18 @@ static char *parse_value(struct config_source *cf)
906
default:
907
return NULL;
908
}
909
- strbuf_addch(&cf->value, c);
909
+ strbuf_addch(&cs->value, c);
910
continue;
911
}
912
if (c == '"') {
913
quote = 1-quote;
914
continue;
915
}
916
- strbuf_addch(&cf->value, c);
916
+ strbuf_addch(&cs->value, c);
917
}
918
}
919
920
-static int get_value(struct config_source *cf, config_fn_t fn, void *data,
920
+static int get_value(struct config_source *cs, config_fn_t fn, void *data,
921
struct strbuf *name)
922
{
923
int c;
@@ -926,8 +926,8 @@ static int get_value(struct config_source *cf, config_fn_t fn, void *data,
926
927
/* Get the full name */
928
for (;;) {
929
- c = get_next_char(cf);
930
- if (cf->eof)
929
+ c = get_next_char(cs);
930
+ if (cs->eof)
931
break;
932
if (!iskeychar(c))
933
break;
@@ -935,13 +935,13 @@ static int get_value(struct config_source *cf, config_fn_t fn, void *data,
935
}
936
937
while (c == ' ' || c == '\t')
938
- c = get_next_char(cf);
938
+ c = get_next_char(cs);
939
940
value = NULL;
941
if (c != '\n') {
942
if (c != '=')
943
return -1;
944
- value = parse_value(cf);
944
+ value = parse_value(cs);
945
if (!value)
946
return -1;
947
}
@@ -950,21 +950,21 @@ static int get_value(struct config_source *cf, config_fn_t fn, void *data,
950
* the line we just parsed during the call to fn to get
951
* accurate line number in error messages.
952
*/
953
- cf->linenr--;
953
+ cs->linenr--;
954
ret = fn(name->buf, value, data);
955
if (ret >= 0)
956
- cf->linenr++;
956
+ cs->linenr++;
957
return ret;
958
}
959
960
-static int get_extended_base_var(struct config_source *cf, struct strbuf *name,
960
+static int get_extended_base_var(struct config_source *cs, struct strbuf *name,
961
int c)
962
{
963
- cf->subsection_case_sensitive = 0;
963
+ cs->subsection_case_sensitive = 0;
964
do {
965
if (c == '\n')
966
goto error_incomplete_line;
967
- c = get_next_char(cf);
967
+ c = get_next_char(cs);
968
} while (isspace(c));
969
970
/* We require the format to be '[base "extension"]' */
@@ -973,13 +973,13 @@ static int get_extended_base_var(struct config_source *cf, struct strbuf *name,
973
strbuf_addch(name, '.');
974
975
for (;;) {
976
- int c = get_next_char(cf);
976
+ int c = get_next_char(cs);
977
if (c == '\n')
978
goto error_incomplete_line;
979
if (c == '"')
980
break;
981
if (c == '\\') {
982
- c = get_next_char(cf);
982
+ c = get_next_char(cs);
983
if (c == '\n')
984
goto error_incomplete_line;
985
}
@@ -987,25 +987,25 @@ static int get_extended_base_var(struct config_source *cf, struct strbuf *name,
987
}
988
989
/* Final ']' */
990
- if (get_next_char(cf) != ']')
990
+ if (get_next_char(cs) != ']')
991
return -1;
992
return 0;
993
error_incomplete_line:
994
- cf->linenr--;
994
+ cs->linenr--;
995
return -1;
996
}
997
998
-static int get_base_var(struct config_source *cf, struct strbuf *name)
998
+static int get_base_var(struct config_source *cs, struct strbuf *name)
999
{
1000
- cf->subsection_case_sensitive = 1;
1000
+ cs->subsection_case_sensitive = 1;
1001
for (;;) {
1002
- int c = get_next_char(cf);
1003
- if (cf->eof)
1002
+ int c = get_next_char(cs);
1003
+ if (cs->eof)
1004
return -1;
1005
if (c == ']')
1006
return 0;
1007
if (isspace(c))
1008
- return get_extended_base_var(cf, name, c);
1008
+ return get_extended_base_var(cs, name, c);
1009
if (!iskeychar(c) && c != '.')
1010
return -1;
1011
strbuf_addch(name, tolower(c));
@@ -1018,7 +1018,7 @@ struct parse_event_data {
1018
const struct config_options *opts;
1019
};
1020
1021
-static int do_event(struct config_source *cf, enum config_event_t type,
1021
+static int do_event(struct config_source *cs, enum config_event_t type,
1022
struct parse_event_data *data)
1023
{
1024
size_t offset;
@@ -1030,7 +1030,7 @@ static int do_event(struct config_source *cf, enum config_event_t type,
1030
data->previous_type == type)
1031
return 0;
1032
1033
- offset = cf->do_ftell(cf);
1033
+ offset = cs->do_ftell(cs);
1034
/*
1035
* At EOF, the parser always "inserts" an extra '\n', therefore
1036
* the end offset of the event is the current file position, otherwise
@@ -1050,12 +1050,12 @@ static int do_event(struct config_source *cf, enum config_event_t type,
1050
return 0;
1051
}
1052
1053
-static int git_parse_source(struct config_source *cf, config_fn_t fn,
1053
+static int git_parse_source(struct config_source *cs, config_fn_t fn,
1054
void *data, const struct config_options *opts)
1055
{
1056
int comment = 0;
1057
size_t baselen = 0;
1058
- struct strbuf *var = &cf->var;
1058
+ struct strbuf *var = &cs->var;
1059
int error_return = 0;
1060
char *error_msg = NULL;
1061
@@ -1070,7 +1070,7 @@ static int git_parse_source(struct config_source *cf, config_fn_t fn,
1070
for (;;) {
1071
int c;
1072
1073
- c = get_next_char(cf);
1073
+ c = get_next_char(cs);
1074
if (bomptr && *bomptr) {
1075
/* We are at the file beginning; skip UTF8-encoded BOM
1076
* if present. Sane editors won't put this in on their
@@ -1087,12 +1087,12 @@ static int git_parse_source(struct config_source *cf, config_fn_t fn,
1087
}
1088
}
1089
if (c == '\n') {
1090
- if (cf->eof) {
1091
- if (do_event(cf, CONFIG_EVENT_EOF, &event_data) < 0)
1090
+ if (cs->eof) {
1091
+ if (do_event(cs, CONFIG_EVENT_EOF, &event_data) < 0)
1092
return -1;
1093
return 0;
1094
}
1095
- if (do_event(cf, CONFIG_EVENT_WHITESPACE, &event_data) < 0)
1095
+ if (do_event(cs, CONFIG_EVENT_WHITESPACE, &event_data) < 0)
1096
return -1;
1097
comment = 0;
1098
continue;
@@ -1100,23 +1100,23 @@ static int git_parse_source(struct config_source *cf, config_fn_t fn,
1100
if (comment)
1101
continue;
1102
if (isspace(c)) {
1103
- if (do_event(cf, CONFIG_EVENT_WHITESPACE, &event_data) < 0)
1103
+ if (do_event(cs, CONFIG_EVENT_WHITESPACE, &event_data) < 0)
1104
return -1;
1105
continue;
1106
}
1107
if (c == '#' || c == ';') {
1108
- if (do_event(cf, CONFIG_EVENT_COMMENT, &event_data) < 0)
1108
+ if (do_event(cs, CONFIG_EVENT_COMMENT, &event_data) < 0)
1109
return -1;
1110
comment = 1;
1111
continue;
1112
}
1113
if (c == '[') {
1114
- if (do_event(cf, CONFIG_EVENT_SECTION, &event_data) < 0)
1114
+ if (do_event(cs, CONFIG_EVENT_SECTION, &event_data) < 0)
1115
return -1;
1116
1117
/* Reset prior to determining a new stem */
1118
strbuf_reset(var);
1119
- if (get_base_var(cf, var) < 0 || var->len < 1)
1119
+ if (get_base_var(cs, var) < 0 || var->len < 1)
1120
break;
1121
strbuf_addch(var, '.');
1122
baselen = var->len;
@@ -1125,7 +1125,7 @@ static int git_parse_source(struct config_source *cf, config_fn_t fn,
1125
if (!isalpha(c))
1126
break;
1127
1128
- if (do_event(cf, CONFIG_EVENT_ENTRY, &event_data) < 0)
1128
+ if (do_event(cs, CONFIG_EVENT_ENTRY, &event_data) < 0)
1129
return -1;
1130
1131
/*
@@ -1135,42 +1135,42 @@ static int git_parse_source(struct config_source *cf, config_fn_t fn,
1135
*/
1136
strbuf_setlen(var, baselen);
1137
strbuf_addch(var, tolower(c));
1138
- if (get_value(cf, fn, data, var) < 0)
1138
+ if (get_value(cs, fn, data, var) < 0)
1139
break;
1140
}
1141
1142
- if (do_event(cf, CONFIG_EVENT_ERROR, &event_data) < 0)
1142
+ if (do_event(cs, CONFIG_EVENT_ERROR, &event_data) < 0)
1143
return -1;
1144
1145
- switch (cf->origin_type) {
1145
+ switch (cs->origin_type) {
1146
case CONFIG_ORIGIN_BLOB:
1147
error_msg = xstrfmt(_("bad config line %d in blob %s"),
1148
- cf->linenr, cf->name);
1148
+ cs->linenr, cs->name);
1149
break;
1150
case CONFIG_ORIGIN_FILE:
1151
error_msg = xstrfmt(_("bad config line %d in file %s"),
1152
- cf->linenr, cf->name);
1152
+ cs->linenr, cs->name);
1153
break;
1154
case CONFIG_ORIGIN_STDIN:
1155
error_msg = xstrfmt(_("bad config line %d in standard input"),
1156
- cf->linenr);
1156
+ cs->linenr);
1157
break;
1158
case CONFIG_ORIGIN_SUBMODULE_BLOB:
1159
error_msg = xstrfmt(_("bad config line %d in submodule-blob %s"),
1160
- cf->linenr, cf->name);
1160
+ cs->linenr, cs->name);
1161
break;
1162
case CONFIG_ORIGIN_CMDLINE:
1163
error_msg = xstrfmt(_("bad config line %d in command line %s"),
1164
- cf->linenr, cf->name);
1164
+ cs->linenr, cs->name);
1165
break;
1166
default:
1167
error_msg = xstrfmt(_("bad config line %d in %s"),
1168
- cf->linenr, cf->name);
1168
+ cs->linenr, cs->name);
1169
}
1170
1171
switch (opts && opts->error_action ?
1172
opts->error_action :
1173
- cf->default_error_action) {
1173
+ cs->default_error_action) {
1174
case CONFIG_ERROR_DIE:
1175
die("%s", error_msg);
1176
break;
@@ -2280,13 +2280,13 @@ int config_with_options(config_fn_t fn, void *data,
2280
return ret;
2281
}
2282
2283
-static void configset_iter(struct config_reader *reader, struct config_set *cs,
2283
+static void configset_iter(struct config_reader *reader, struct config_set *set,
2284
config_fn_t fn, void *data)
2285
{
2286
int i, value_index;
2287
struct string_list *values;
2288
struct config_set_element *entry;
2289
- struct configset_list *list = &cs->list;
2289
+ struct configset_list *list = &set->list;
2290
2291
for (i = 0; i < list->nr; i++) {
2292
entry = list->items[i].e;
@@ -2351,7 +2351,7 @@ void read_very_early_config(config_fn_t cb, void *data)
2351
config_with_options(cb, data, NULL, &opts);
2352
}
2353
2354
-static struct config_set_element *configset_find_element(struct config_set *cs, const char *key)
2354
+static struct config_set_element *configset_find_element(struct config_set *set, const char *key)
2355
{
2356
struct config_set_element k;
2357
struct config_set_element *found_entry;
@@ -2365,13 +2365,13 @@ static struct config_set_element *configset_find_element(struct config_set *cs,
2365
2366
hashmap_entry_init(&k.ent, strhash(normalized_key));
2367
k.key = normalized_key;
2368
- found_entry = hashmap_get_entry(&cs->config_hash, &k, ent, NULL);
2368
+ found_entry = hashmap_get_entry(&set->config_hash, &k, ent, NULL);
2369
free(normalized_key);
2370
return found_entry;
2371
}
2372
2373
static int configset_add_value(struct config_reader *reader,
2374
- struct config_set *cs, const char *key,
2374
+ struct config_set *set, const char *key,
2375
const char *value)
2376
{
2377
struct config_set_element *e;
@@ -2379,7 +2379,7 @@ static int configset_add_value(struct config_reader *reader,
2379
struct configset_list_item *l_item;
2380
struct key_value_info *kv_info = xmalloc(sizeof(*kv_info));
2381
2382
- e = configset_find_element(cs, key);
2382
+ e = configset_find_element(set, key);
2383
/*
2384
* Since the keys are being fed by git_config*() callback mechanism, they
2385
* are already normalized. So simply add them without any further munging.
@@ -2389,12 +2389,12 @@ static int configset_add_value(struct config_reader *reader,
2389
hashmap_entry_init(&e->ent, strhash(key));
2390
e->key = xstrdup(key);
2391
string_list_init_dup(&e->value_list);
2392
- hashmap_add(&cs->config_hash, &e->ent);
2392
+ hashmap_add(&set->config_hash, &e->ent);
2393
}
2394
si = string_list_append_nodup(&e->value_list, xstrdup_or_null(value));
2395
2396
- ALLOC_GROW(cs->list.items, cs->list.nr + 1, cs->list.alloc);
2397
- l_item = &cs->list.items[cs->list.nr++];
2396
+ ALLOC_GROW(set->list.items, set->list.nr + 1, set->list.alloc);
2397
+ l_item = &set->list.items[set->list.nr++];
2398
l_item->e = e;
2399
l_item->value_index = e->value_list.nr - 1;
2400
@@ -2429,33 +2429,33 @@ static int config_set_element_cmp(const void *cmp_data UNUSED,
2429
return strcmp(e1->key, e2->key);
2430
}
2431
2432
-void git_configset_init(struct config_set *cs)
2432
+void git_configset_init(struct config_set *set)
2433
{
2434
- hashmap_init(&cs->config_hash, config_set_element_cmp, NULL, 0);
2435
- cs->hash_initialized = 1;
2436
- cs->list.nr = 0;
2437
- cs->list.alloc = 0;
2438
- cs->list.items = NULL;
2434
+ hashmap_init(&set->config_hash, config_set_element_cmp, NULL, 0);
2435
+ set->hash_initialized = 1;
2436
+ set->list.nr = 0;
2437
+ set->list.alloc = 0;
2438
+ set->list.items = NULL;
2439
}
2440
2441
-void git_configset_clear(struct config_set *cs)
2441
+void git_configset_clear(struct config_set *set)
2442
{
2443
struct config_set_element *entry;
2444
struct hashmap_iter iter;
2445
- if (!cs->hash_initialized)
2445
+ if (!set->hash_initialized)
2446
return;
2447
2448
- hashmap_for_each_entry(&cs->config_hash, &iter, entry,
2448
+ hashmap_for_each_entry(&set->config_hash, &iter, entry,
2449
ent /* member name */) {
2450
free(entry->key);
2451
string_list_clear(&entry->value_list, 1);
2452
}
2453
- hashmap_clear_and_free(&cs->config_hash, struct config_set_element, ent);
2454
- cs->hash_initialized = 0;
2455
- free(cs->list.items);
2456
- cs->list.nr = 0;
2457
- cs->list.alloc = 0;
2458
- cs->list.items = NULL;
2453
+ hashmap_clear_and_free(&set->config_hash, struct config_set_element, ent);
2454
+ set->hash_initialized = 0;
2455
+ free(set->list.items);
2456
+ set->list.nr = 0;
2457
+ set->list.alloc = 0;
2458
+ set->list.items = NULL;
2459
}
2460
2461
struct configset_add_data {
@@ -2471,15 +2471,15 @@ static int config_set_callback(const char *key, const char *value, void *cb)
2471
return 0;
2472
}
2473
2474
-int git_configset_add_file(struct config_set *cs, const char *filename)
2474
+int git_configset_add_file(struct config_set *set, const char *filename)
2475
{
2476
struct configset_add_data data = CONFIGSET_ADD_INIT;
2477
data.config_reader = &the_reader;
2478
- data.config_set = cs;
2478
+ data.config_set = set;
2479
return git_config_from_file(config_set_callback, filename, &data);
2480
}
2481
2482
-int git_configset_get_value(struct config_set *cs, const char *key, const char **value)
2482
+int git_configset_get_value(struct config_set *set, const char *key, const char **value)
2483
{
2484
const struct string_list *values = NULL;
2485
/*
@@ -2487,7 +2487,7 @@ int git_configset_get_value(struct config_set *cs, const char *key, const char *
2487
* queried key in the files of the configset, the value returned will be the last
2488
* value in the value list for that key.
2489
*/
2490
- values = git_configset_get_value_multi(cs, key);
2490
+ values = git_configset_get_value_multi(set, key);
2491
2492
if (!values)
2493
return 1;
@@ -2496,26 +2496,26 @@ int git_configset_get_value(struct config_set *cs, const char *key, const char *
2496
return 0;
2497
}
2498
2499
-const struct string_list *git_configset_get_value_multi(struct config_set *cs, const char *key)
2499
+const struct string_list *git_configset_get_value_multi(struct config_set *set, const char *key)
2500
{
2501
- struct config_set_element *e = configset_find_element(cs, key);
2501
+ struct config_set_element *e = configset_find_element(set, key);
2502
return e ? &e->value_list : NULL;
2503
}
2504
2505
-int git_configset_get_string(struct config_set *cs, const char *key, char **dest)
2505
+int git_configset_get_string(struct config_set *set, const char *key, char **dest)
2506
{
2507
const char *value;
2508
- if (!git_configset_get_value(cs, key, &value))
2508
+ if (!git_configset_get_value(set, key, &value))
2509
return git_config_string((const char **)dest, key, value);
2510
else
2511
return 1;
2512
}
2513
2514
-static int git_configset_get_string_tmp(struct config_set *cs, const char *key,
2514
+static int git_configset_get_string_tmp(struct config_set *set, const char *key,
2515
const char **dest)
2516
{
2517
const char *value;
2518
- if (!git_configset_get_value(cs, key, &value)) {
2518
+ if (!git_configset_get_value(set, key, &value)) {
2519
if (!value)
2520
return config_error_nonbool(key);
2521
*dest = value;
@@ -2525,51 +2525,51 @@ static int git_configset_get_string_tmp(struct config_set *cs, const char *key,
2525
}
2526
}
2527
2528
-int git_configset_get_int(struct config_set *cs, const char *key, int *dest)
2528
+int git_configset_get_int(struct config_set *set, const char *key, int *dest)
2529
{
2530
const char *value;
2531
- if (!git_configset_get_value(cs, key, &value)) {
2531
+ if (!git_configset_get_value(set, key, &value)) {
2532
*dest = git_config_int(key, value);
2533
return 0;
2534
} else
2535
return 1;
2536
}
2537
2538
-int git_configset_get_ulong(struct config_set *cs, const char *key, unsigned long *dest)
2538
+int git_configset_get_ulong(struct config_set *set, const char *key, unsigned long *dest)
2539
{
2540
const char *value;
2541
- if (!git_configset_get_value(cs, key, &value)) {
2541
+ if (!git_configset_get_value(set, key, &value)) {
2542
*dest = git_config_ulong(key, value);
2543
return 0;
2544
} else
2545
return 1;
2546
}
2547
2548
-int git_configset_get_bool(struct config_set *cs, const char *key, int *dest)
2548
+int git_configset_get_bool(struct config_set *set, const char *key, int *dest)
2549
{
2550
const char *value;
2551
- if (!git_configset_get_value(cs, key, &value)) {
2551
+ if (!git_configset_get_value(set, key, &value)) {
2552
*dest = git_config_bool(key, value);
2553
return 0;
2554
} else
2555
return 1;
2556
}
2557
2558
-int git_configset_get_bool_or_int(struct config_set *cs, const char *key,
2558
+int git_configset_get_bool_or_int(struct config_set *set, const char *key,
2559
int *is_bool, int *dest)
2560
{
2561
const char *value;
2562
- if (!git_configset_get_value(cs, key, &value)) {
2562
+ if (!git_configset_get_value(set, key, &value)) {
2563
*dest = git_config_bool_or_int(key, value, is_bool);
2564
return 0;
2565
} else
2566
return 1;
2567
}
2568
2569
-int git_configset_get_maybe_bool(struct config_set *cs, const char *key, int *dest)
2569
+int git_configset_get_maybe_bool(struct config_set *set, const char *key, int *dest)
2570
{
2571
const char *value;
2572
- if (!git_configset_get_value(cs, key, &value)) {
2572
+ if (!git_configset_get_value(set, key, &value)) {
2573
*dest = git_parse_maybe_bool(value);
2574
if (*dest == -1)
2575
return -1;
@@ -2578,10 +2578,10 @@ int git_configset_get_maybe_bool(struct config_set *cs, const char *key, int *de
2578
return 1;
2579
}
2580
2581
-int git_configset_get_pathname(struct config_set *cs, const char *key, const char **dest)
2581
+int git_configset_get_pathname(struct config_set *set, const char *key, const char **dest)
2582
{
2583
const char *value;
2584
- if (!git_configset_get_value(cs, key, &value))
2584
+ if (!git_configset_get_value(set, key, &value))
2585
return git_config_pathname(dest, key, value);
2586
else
2587
return 1;
@@ -2972,7 +2972,7 @@ static int store_aux_event(enum config_event_t type,
2972
size_t begin, size_t end, void *data)
2973
{
2974
struct config_store_data *store = data;
2975
- struct config_source *cf = store->config_reader->source;
2975
+ struct config_source *cs = store->config_reader->source;
2976
2977
ALLOC_GROW(store->parsed, store->parsed_nr + 1, store->parsed_alloc);
2978
store->parsed[store->parsed_nr].begin = begin;
@@ -2982,10 +2982,10 @@ static int store_aux_event(enum config_event_t type,
2982
if (type == CONFIG_EVENT_SECTION) {
2983
int (*cmpfn)(const char *, const char *, size_t);
2984
2985
- if (cf->var.len < 2 || cf->var.buf[cf->var.len - 1] != '.')
2986
- return error(_("invalid section name '%s'"), cf->var.buf);
2985
+ if (cs->var.len < 2 || cs->var.buf[cs->var.len - 1] != '.')
2986
+ return error(_("invalid section name '%s'"), cs->var.buf);
2987
2988
- if (cf->subsection_case_sensitive)
2988
+ if (cs->subsection_case_sensitive)
2989
cmpfn = strncasecmp;
2990
else
2991
cmpfn = strncmp;
@@ -2993,8 +2993,8 @@ static int store_aux_event(enum config_event_t type,
2993
/* Is this the section we were looking for? */
2994
store->is_keys_section =
2995
store->parsed[store->parsed_nr].is_keys_section =
2996
- cf->var.len - 1 == store->baselen &&
2997
- !cmpfn(cf->var.buf, store->key, store->baselen);
2996
+ cs->var.len - 1 == store->baselen &&
2997
+ !cmpfn(cs->var.buf, store->key, store->baselen);
2998
if (store->is_keys_section) {
2999
store->section_seen = 1;
3000
ALLOC_GROW(store->seen, store->seen_nr + 1,