mirror of
https://git.proxmox.com/git/libgit2
synced 2025-08-05 12:52:58 +00:00
config: deduplicate iterator creation
When the glob iterator is passed NULL regexp, call the non-globbing iterator so we don't have to special-case which functions to call.
This commit is contained in:
parent
d8289b9fb4
commit
86c0261460
21
src/config.c
21
src/config.c
@ -449,23 +449,20 @@ int git_config_iterator_glob_new(git_config_iterator **out, const git_config *cf
|
|||||||
all_iter *iter;
|
all_iter *iter;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
|
if (regexp == NULL)
|
||||||
|
return git_config_iterator_new(out, cfg);
|
||||||
|
|
||||||
iter = git__calloc(1, sizeof(all_iter));
|
iter = git__calloc(1, sizeof(all_iter));
|
||||||
GITERR_CHECK_ALLOC(iter);
|
GITERR_CHECK_ALLOC(iter);
|
||||||
|
|
||||||
if (regexp != NULL) {
|
if ((result = regcomp(&iter->regex, regexp, REG_EXTENDED)) < 0) {
|
||||||
if ((result = regcomp(&iter->regex, regexp, REG_EXTENDED)) < 0) {
|
giterr_set_regex(&iter->regex, result);
|
||||||
giterr_set_regex(&iter->regex, result);
|
regfree(&iter->regex);
|
||||||
regfree(&iter->regex);
|
return -1;
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
iter->parent.next = all_iter_glob_next;
|
|
||||||
iter->parent.free = all_iter_glob_free;
|
|
||||||
} else {
|
|
||||||
iter->parent.next = all_iter_next;
|
|
||||||
iter->parent.free = all_iter_free;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
iter->parent.next = all_iter_glob_next;
|
||||||
|
iter->parent.free = all_iter_glob_free;
|
||||||
iter->i = cfg->files.length;
|
iter->i = cfg->files.length;
|
||||||
iter->cfg = cfg;
|
iter->cfg = cfg;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user