diff options
author | Russell Belfer <rb@github.com> | 2012-07-10 15:22:39 -0700 |
---|---|---|
committer | Russell Belfer <rb@github.com> | 2012-07-10 23:19:47 -0700 |
commit | b3ff1dab317dc9194c4bc124afd95ae9be2ad57b (patch) | |
tree | c031792209b9758395610720b8dbfb776165f783 /src/config_file.h | |
parent | c3a875c975cde11ffd18947c419b1cd38205e6c3 (diff) | |
download | libgit2-b3ff1dab317dc9194c4bc124afd95ae9be2ad57b.tar.gz |
Adding git_config_foreach_match() iteration fn
Adding a new config iteration function that let's you iterate
over just the config entries that match a particular regular
expression. The old foreach becomes a simple use of this with
an empty pattern.
This also fixes an apparent bug in the existing `git_config_foreach`
where returning a non-zero value from the iteration callback was
not correctly aborting the iteration and the returned value was
not being propogated back to the caller of foreach.
Added to tests to cover all these changes.
Diffstat (limited to 'src/config_file.h')
-rw-r--r-- | src/config_file.h | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/config_file.h b/src/config_file.h index 0080b5713..c31292881 100644 --- a/src/config_file.h +++ b/src/config_file.h @@ -19,12 +19,27 @@ GIT_INLINE(void) git_config_file_free(git_config_file *cfg) cfg->free(cfg); } +GIT_INLINE(int) git_config_file_set_string( + git_config_file *cfg, const char *name, const char *value) +{ + return cfg->set(cfg, name, value); +} + GIT_INLINE(int) git_config_file_foreach( git_config_file *cfg, int (*fn)(const char *key, const char *value, void *data), void *data) { - return cfg->foreach(cfg, fn, data); + return cfg->foreach(cfg, NULL, fn, data); +} + +GIT_INLINE(int) git_config_file_foreach_match( + git_config_file *cfg, + const char *regexp, + int (*fn)(const char *key, const char *value, void *data), + void *data) +{ + return cfg->foreach(cfg, regexp, fn, data); } #endif |