line |
true |
false |
branch |
27
|
2097 |
893 |
if (!entry) |
54
|
1134 |
571 |
for (i = 0; i < cfg->backends.length; ++i) { |
56
|
1134 |
0 |
GIT_REFCOUNT_DEC(internal, backend_internal_free); |
|
1134 |
0 |
GIT_REFCOUNT_DEC(internal, backend_internal_free); |
67
|
5 |
586 |
if (cfg == NULL) |
70
|
571 |
15 |
GIT_REFCOUNT_DEC(cfg, config_free); |
|
571 |
0 |
GIT_REFCOUNT_DEC(cfg, config_free); |
86
|
0 |
573 |
GIT_ERROR_CHECK_ALLOC(cfg); |
90
|
0 |
573 |
if (git_vector_init(&cfg->backends, 3, config_backend_cmp) < 0) { |
111
|
134 |
0 |
assert(cfg && path); |
|
0 |
134 |
assert(cfg && path); |
114
|
66 |
68 |
if (res < 0 && errno != ENOENT && errno != ENOTDIR) { |
|
0 |
66 |
if (res < 0 && errno != ENOENT && errno != ENOTDIR) { |
|
0 |
0 |
if (res < 0 && errno != ENOENT && errno != ENOTDIR) { |
119
|
0 |
134 |
if (git_config_backend_from_file(&file, path) < 0) |
122
|
0 |
134 |
if ((res = git_config_add_backend(cfg, file, level, repo, force)) < 0) { |
141
|
0 |
5 |
if (git_config_new(&config) < 0) |
144
|
0 |
5 |
if ((error = git_config_add_file_ondisk(config, path, GIT_CONFIG_LEVEL_LOCAL, NULL, 0)) < 0) |
161
|
0 |
502 |
if (git_config_new(&config) < 0) |
164
|
1004 |
502 |
git_vector_foreach(&in->backends, i, internal) { |
167
|
0 |
1004 |
if ((error = internal->backend->snapshot(&b, internal->backend)) < 0) |
170
|
0 |
1004 |
if ((error = git_config_add_backend(config, b, internal->level, NULL, 0)) < 0) { |
176
|
0 |
502 |
if (error < 0) |
198
|
0 |
0 |
if (level == GIT_CONFIG_HIGHEST_LEVEL) { |
201
|
0 |
0 |
git_vector_foreach(&cfg->backends, i, internal) { |
202
|
0 |
0 |
if (internal->level == level) |
207
|
0 |
0 |
if (pos == -1) { |
236
|
0 |
0 |
git_vector_foreach(&cfg->backends, i, internal) { |
237
|
0 |
0 |
if (internal->level == level) |
241
|
0 |
0 |
if (pos == -1) |
246
|
0 |
0 |
if (git_vector_remove(&cfg->backends, pos) < 0) |
249
|
0 |
0 |
GIT_REFCOUNT_DEC(internal, backend_internal_free); |
|
0 |
0 |
GIT_REFCOUNT_DEC(internal, backend_internal_free); |
261
|
0 |
1138 |
if (force) |
264
|
0 |
1138 |
if ((result = git_vector_insert_sorted(&cfg->backends, |
278
|
0 |
0 |
if (!git_config_open_level(cfg_out, cfg, GIT_CONFIG_LEVEL_XDG)) |
293
|
0 |
0 |
if ((res = find_backend_by_level(&internal, cfg_parent, level)) < 0) |
296
|
0 |
0 |
if ((res = git_config_new(&cfg)) < 0) |
299
|
0 |
0 |
if ((res = git_config__add_internal(cfg, internal, level, true)) < 0) { |
319
|
1138 |
0 |
assert(cfg && backend); |
|
0 |
1138 |
assert(cfg && backend); |
321
|
0 |
1138 |
GIT_ERROR_CHECK_VERSION(backend, GIT_CONFIG_BACKEND_VERSION, "git_config_backend"); |
323
|
0 |
1138 |
if ((result = backend->open(backend, level, repo)) < 0) |
327
|
0 |
1138 |
GIT_ERROR_CHECK_ALLOC(internal); |
334
|
0 |
1138 |
if ((result = git_config__add_internal(cfg, internal, level, force)) < 0) { |
358
|
104 |
51 |
for (; i > 0; --i) { |
360
|
104 |
0 |
if (!internal || !internal->backend) |
|
0 |
104 |
if (!internal || !internal->backend) |
378
|
853 |
52 |
if (iter->current != NULL && |
|
802 |
51 |
if (iter->current != NULL && |
383
|
51 |
52 |
if (error < 0 && error != GIT_ITEROVER) |
|
0 |
51 |
if (error < 0 && error != GIT_ITEROVER) |
387
|
51 |
104 |
if (find_next_backend(&i, iter->cfg, iter->i) < 0) |
394
|
52 |
52 |
if (iter->current) |
399
|
0 |
104 |
if (error == GIT_ENOTFOUND) |
402
|
0 |
104 |
if (error < 0) |
407
|
52 |
52 |
if (error == GIT_ITEROVER) |
426
|
453 |
26 |
while ((error = all_iter_next(entry, _iter)) == 0) { |
428
|
439 |
14 |
if (git_regexp_match(&iter->regex, (*entry)->name) != 0) |
442
|
52 |
0 |
if (iter->current) |
461
|
0 |
26 |
GIT_ERROR_CHECK_ALLOC(iter); |
479
|
2 |
26 |
if (regexp == NULL) |
483
|
0 |
26 |
GIT_ERROR_CHECK_ALLOC(iter); |
485
|
0 |
26 |
if ((result = git_regexp_compile(&iter->regex, regexp, 0)) < 0) { |
517
|
0 |
0 |
assert(backend && cb); |
|
0 |
0 |
assert(backend && cb); |
519
|
0 |
0 |
if (regexp && git_regexp_compile(®ex, regexp, 0) < 0) |
|
0 |
0 |
if (regexp && git_regexp_compile(®ex, regexp, 0) < 0) |
522
|
0 |
0 |
if ((error = backend->iterator(&iter, backend)) < 0) { |
527
|
0 |
0 |
while (!(iter->next(&entry, iter) < 0)) { |
529
|
0 |
0 |
if (regexp && git_regexp_match(®ex, entry->name) != 0) |
|
0 |
0 |
if (regexp && git_regexp_match(®ex, entry->name) != 0) |
533
|
0 |
0 |
if ((error = cb(entry, payload)) != 0) { |
539
|
0 |
0 |
if (regexp != NULL) |
557
|
0 |
9 |
if ((error = git_config_iterator_glob_new(&iter, cfg, regexp)) < 0) |
560
|
26 |
8 |
while (!(error = git_config_next(&entry, iter))) { |
561
|
1 |
25 |
if ((error = cb(entry, payload)) != 0) { |
569
|
8 |
1 |
if (error == GIT_ITEROVER) |
597
|
0 |
60 |
if (git_vector_length(&cfg->backends) == 0) { |
604
|
60 |
0 |
git_vector_foreach(&cfg->backends, i, backend) { |
605
|
60 |
0 |
if (!backend->backend->readonly) { |
621
|
0 |
15 |
if (get_backend_for_use(&backend, cfg, name, BACKEND_USE_DELETE) < 0) |
641
|
12 |
5 |
return git_config_set_string(cfg, name, value ? "true" : "false"); |
649
|
0 |
40 |
if (!value) { |
654
|
0 |
40 |
if (get_backend_for_use(&backend, cfg, name, BACKEND_USE_SET) < 0) |
659
|
40 |
0 |
if (!error && GIT_REFCOUNT_OWNER(cfg) != NULL) |
|
21 |
19 |
if (!error && GIT_REFCOUNT_OWNER(cfg) != NULL) |
675
|
0 |
0 |
if ((error = git_config__lookup_entry(&ce, config, key, false)) < 0) |
678
|
0 |
0 |
if (!ce && only_if_existing) /* entry doesn't exist */ |
|
0 |
0 |
if (!ce && only_if_existing) /* entry doesn't exist */ |
680
|
0 |
0 |
if (ce && !overwrite_existing) /* entry would be overwritten */ |
|
0 |
0 |
if (ce && !overwrite_existing) /* entry would be overwritten */ |
682
|
0 |
0 |
if (value && ce && ce->value && !strcmp(ce->value, value)) /* no change */ |
|
0 |
0 |
if (value && ce && ce->value && !strcmp(ce->value, value)) /* no change */ |
|
0 |
0 |
if (value && ce && ce->value && !strcmp(ce->value, value)) /* no change */ |
|
0 |
0 |
if (value && ce && ce->value && !strcmp(ce->value, value)) /* no change */ |
684
|
0 |
0 |
if (!value && (!ce || !ce->value)) /* asked to delete absent entry */ |
|
0 |
0 |
if (!value && (!ce || !ce->value)) /* asked to delete absent entry */ |
|
0 |
0 |
if (!value && (!ce || !ce->value)) /* asked to delete absent entry */ |
687
|
0 |
0 |
if (!value) |
727
|
483 |
2566 |
if (normalize_name) { |
728
|
0 |
483 |
if ((res = git_config__normalize_name(name, &normalized)) < 0) |
734
|
5205 |
2156 |
git_vector_foreach(&cfg->backends, i, internal) { |
735
|
5205 |
0 |
if (!internal || !internal->backend) |
|
0 |
5205 |
if (!internal || !internal->backend) |
739
|
893 |
4312 |
if (res != GIT_ENOTFOUND) |
746
|
2156 |
893 |
if (res == GIT_ENOTFOUND) |
747
|
157 |
1999 |
res = (want_errors > GET_ALL_ERRORS) ? 0 : config_error_notfound(name); |
748
|
0 |
893 |
else if (res && (want_errors == GET_NO_ERRORS)) { |
|
0 |
0 |
else if (res && (want_errors == GET_NO_ERRORS)) { |
768
|
284 |
1614 |
return get_entry( |
782
|
0 |
0 |
if ((ret = get_entry(&entry, cfg, name, true, GET_ALL_ERRORS)) < 0) |
796
|
28 |
0 |
if ((ret = get_entry(&entry, cfg, name, true, GET_ALL_ERRORS)) < 0) |
810
|
1 |
64 |
if ((ret = get_entry(&entry, cfg, name, true, GET_ALL_ERRORS)) < 0) |
824
|
30 |
65 |
if ((ret = get_entry(&entry, cfg, name, true, GET_ALL_ERRORS)) < 0) |
838
|
396 |
198 |
git_vector_foreach(&cfg->backends, i, internal) { |
839
|
396 |
0 |
if (!internal || !internal->backend) |
|
0 |
396 |
if (!internal || !internal->backend) |
842
|
0 |
396 |
if (!internal->backend->readonly) |
854
|
0 |
0 |
if ((error = get_entry(&entry, cfg, name, true, GET_ALL_ERRORS)) < 0) |
869
|
0 |
198 |
if (!is_readonly(cfg)) { |
875
|
171 |
27 |
*out = !ret ? (entry->value ? entry->value : "") : NULL; |
|
171 |
0 |
*out = !ret ? (entry->value ? entry->value : "") : NULL; |
892
|
15 |
7 |
str = !ret ? (entry->value ? entry->value : "") : NULL; |
|
15 |
0 |
str = !ret ? (entry->value ? entry->value : "") : NULL; |
894
|
15 |
7 |
if (str) |
909
|
0 |
14 |
ret = (entry && entry->value) ? git__strdup(entry->value) : fallback_value ? git__strdup(fallback_value) : NULL; |
|
0 |
0 |
ret = (entry && entry->value) ? git__strdup(entry->value) : fallback_value ? git__strdup(fallback_value) : NULL; |
|
14 |
0 |
ret = (entry && entry->value) ? git__strdup(entry->value) : fallback_value ? git__strdup(fallback_value) : NULL; |
923
|
225 |
373 |
if (entry && git_config_parse_bool(&val, entry->value) < 0) |
|
0 |
225 |
if (entry && git_config_parse_bool(&val, entry->value) < 0) |
938
|
0 |
56 |
if (entry && git_config_parse_int32(&val, entry->value) < 0) |
|
0 |
0 |
if (entry && git_config_parse_int32(&val, entry->value) < 0) |
953
|
0 |
20 |
if ((err = git_config_multivar_iterator_new(&iter, cfg, name, regexp)) < 0) |
957
|
10 |
20 |
while ((err = iter->next(&entry, iter)) == 0) { |
960
|
0 |
10 |
if ((err = cb(entry, payload)) != 0) { |
967
|
20 |
0 |
if (err == GIT_ITEROVER) |
970
|
10 |
10 |
if (found == 0 && err == 0) |
|
10 |
0 |
if (found == 0 && err == 0) |
989
|
389 |
24 |
while ((error = iter->iter->next(entry, iter->iter)) == 0) { |
990
|
374 |
15 |
if (git__strcmp(iter->name, (*entry)->name)) |
993
|
15 |
0 |
if (!iter->have_regex) |
996
|
0 |
0 |
if (git_regexp_match(&iter->regex, (*entry)->value) == 0) |
1010
|
0 |
24 |
if (iter->have_regex) |
1021
|
0 |
24 |
if ((error = git_config_iterator_new(&inner, cfg)) < 0) |
1025
|
0 |
24 |
GIT_ERROR_CHECK_ALLOC(iter); |
1027
|
0 |
24 |
if ((error = git_config__normalize_name(name, &iter->name)) < 0) |
1030
|
0 |
24 |
if (regexp != NULL) { |
1031
|
0 |
0 |
if ((error = git_regexp_compile(&iter->regex, regexp, 0)) < 0) |
1056
|
0 |
5 |
if (get_backend_for_use(&backend, cfg, name, BACKEND_USE_DELETE) < 0) |
1066
|
0 |
0 |
if (get_backend_for_use(&backend, cfg, name, BACKEND_USE_DELETE) < 0) |
1079
|
0 |
1036 |
if (iter == NULL) |
1110
|
64 |
0 |
if (ret != GIT_OK) |
1121
|
0 |
64 |
if (git_sysdir_get(&paths, GIT_SYSDIR_GLOBAL) < 0) |
1125
|
64 |
0 |
if (!paths || !git_buf_len(paths)) |
|
0 |
64 |
if (!paths || !git_buf_len(paths)) |
1129
|
320 |
64 |
for (sep = start = git_buf_cstr(paths); *sep; ++sep) { |
1130
|
0 |
320 |
if (*sep == GIT_PATH_LIST_SEPARATOR && |
|
0 |
0 |
if (*sep == GIT_PATH_LIST_SEPARATOR && |
1131
|
0 |
0 |
(sep <= start || sep[-1] != '\\')) |
1135
|
0 |
64 |
if (git_buf_set(buf, start, (size_t)(sep - start)) < 0) |
1147
|
0 |
1 |
if ((error = git_config_new(&cfg)) < 0) |
1150
|
1 |
0 |
if (!git_config_find_global(&buf) || !git_config__global_location(&buf)) { |
|
1 |
0 |
if (!git_config_find_global(&buf) || !git_config__global_location(&buf)) { |
1155
|
1 |
0 |
if (!error && !git_config_find_xdg(&buf)) |
|
0 |
1 |
if (!error && !git_config_find_xdg(&buf)) |
1159
|
1 |
0 |
if (!error && !git_config_find_system(&buf)) |
|
0 |
1 |
if (!error && !git_config_find_system(&buf)) |
1163
|
1 |
0 |
if (!error && !git_config_find_programdata(&buf)) |
|
0 |
1 |
if (!error && !git_config_find_programdata(&buf)) |
1169
|
0 |
1 |
if (error) { |
1185
|
0 |
0 |
assert(cfg); |
1188
|
0 |
0 |
if (!internal || !internal->backend) { |
|
0 |
0 |
if (!internal || !internal->backend) { |
1194
|
0 |
0 |
if ((error = backend->lock(backend)) < 0) |
1205
|
0 |
0 |
assert(cfg); |
1208
|
0 |
0 |
if (!internal || !internal->backend) { |
|
0 |
0 |
if (!internal || !internal->backend) { |
1230
|
0 |
23 |
if (!value) |
1233
|
53 |
0 |
for (i = 0; i < map_n; ++i) { |
1241
|
32 |
14 |
if (git__parse_bool(&bool_val, value) == 0 && |
|
16 |
16 |
if (git__parse_bool(&bool_val, value) == 0 && |
1250
|
0 |
0 |
if (git_config_parse_int32(out, value) == 0) |
1255
|
7 |
0 |
if (strcasecmp(value, m->str_match) == 0) { |
1273
|
0 |
0 |
for (i = 0; i < map_n; i++) { |
1276
|
0 |
0 |
if (m->map_value != enum_val) |
1290
|
609 |
0 |
if (git__parse_bool(out, value) == 0) |
1293
|
0 |
0 |
if (git_config_parse_int32(out, value) == 0) { |
1307
|
64 |
0 |
if (!value || git__strntol64(&num, value, strlen(value), &num_end, 0) < 0) |
|
64 |
0 |
if (!value || git__strntol64(&num, value, strlen(value), &num_end, 0) < 0) |
1327
|
0 |
0 |
if (num_end[1] != '\0') |
1341
|
0 |
0 |
git_error_set(GIT_ERROR_CONFIG, "failed to parse '%s' as an integer", value ? value : "(null)"); |
1350
|
0 |
64 |
if (git_config_parse_int64(&tmp, value) < 0) |
1354
|
0 |
64 |
if (truncate != tmp) |
1361
|
0 |
0 |
git_error_set(GIT_ERROR_CONFIG, "failed to parse '%s' as a 32-bit integer", value ? value : "(null)"); |
1367
|
0 |
0 |
assert(out && value); |
|
0 |
0 |
assert(out && value); |
1371
|
0 |
0 |
if (value[0] == '~') { |
1372
|
0 |
0 |
if (value[1] != '\0' && value[1] != '/') { |
|
0 |
0 |
if (value[1] != '\0' && value[1] != '/') { |
1377
|
0 |
0 |
return git_sysdir_expand_global_file(out, value[1] ? &value[2] : NULL); |
1387
|
0 |
1136 |
if (start == end) |
1391
|
7779 |
567 |
for (scan = start; *scan; ++scan) { |
1392
|
3111 |
4668 |
if (end && scan >= end) |
|
569 |
2542 |
if (end && scan >= end) |
1394
|
7210 |
0 |
if (isalnum(*scan)) |
1396
|
0 |
0 |
else if (*scan != '-' || scan == start) |
|
0 |
0 |
else if (*scan != '-' || scan == start) |
1400
|
0 |
1136 |
if (scan == start) |
1412
|
567 |
0 |
assert(in && out); |
|
0 |
567 |
assert(in && out); |
1415
|
0 |
567 |
GIT_ERROR_CHECK_ALLOC(name); |
1420
|
567 |
0 |
if (fdot == NULL || fdot == name || ldot == NULL || !ldot[1]) |
|
567 |
0 |
if (fdot == NULL || fdot == name || ldot == NULL || !ldot[1]) |
|
567 |
0 |
if (fdot == NULL || fdot == name || ldot == NULL || !ldot[1]) |
|
567 |
0 |
if (fdot == NULL || fdot == name || ldot == NULL || !ldot[1]) |
1429
|
792 |
567 |
while (fdot < ldot) |
1430
|
0 |
792 |
if (*fdot++ == '\n') |
1456
|
2 |
2 |
if (base_len > 0 && |
|
2 |
0 |
if (base_len > 0 && |
1465
|
4 |
0 |
if (!error) |
1483
|
0 |
3 |
if ((error = git_buf_puts(&pattern, "\\..+")) < 0) |
1486
|
0 |
3 |
if ((error = git_repository_config__weakptr(&config, repo)) < 0) |
1493
|
0 |
3 |
if ((error = git_buf_join(&replace, '.', new_section_name, "")) < 0) |
1496
|
2 |
1 |
if (new_section_name != NULL && |
|
0 |
2 |
if (new_section_name != NULL && |
1516
|
0 |
0 |
GIT_INIT_STRUCTURE_FROM_TEMPLATE( |