config: get_multivar -> get_multivar_foreach The plain function will return an iterator, so move this one out of the way.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283
diff --git a/include/git2/config.h b/include/git2/config.h
index 43bc194..a0dc11b 100644
--- a/include/git2/config.h
+++ b/include/git2/config.h
@@ -328,7 +328,7 @@ GIT_EXTERN(int) git_config_get_bool(int *out, const git_config *cfg, const char
GIT_EXTERN(int) git_config_get_string(const char **out, const git_config *cfg, const char *name);
/**
- * Get each value of a multivar.
+ * Get each value of a multivar in a foreach callback
*
* The callback will be called on each variable found
*
@@ -339,7 +339,7 @@ GIT_EXTERN(int) git_config_get_string(const char **out, const git_config *cfg, c
* @param callback the function to be called on each value of the variable
* @param payload opaque pointer to pass to the callback
*/
-GIT_EXTERN(int) git_config_get_multivar(const git_config *cfg, const char *name, const char *regexp, git_config_foreach_cb callback, void *payload);
+GIT_EXTERN(int) git_config_get_multivar_foreach(const git_config *cfg, const char *name, const char *regexp, git_config_foreach_cb callback, void *payload);
/**
* Set the value of an integer config variable in the config file
diff --git a/include/git2/sys/config.h b/include/git2/sys/config.h
index f617623..09c7963 100644
--- a/include/git2/sys/config.h
+++ b/include/git2/sys/config.h
@@ -31,7 +31,7 @@ struct git_config_backend {
/* Open means open the file/database and parse if necessary */
int (*open)(struct git_config_backend *, git_config_level_t level);
int (*get)(const struct git_config_backend *, const char *key, const git_config_entry **entry);
- int (*get_multivar)(struct git_config_backend *, const char *key, const char *regexp, git_config_foreach_cb callback, void *payload);
+ int (*get_multivar_foreach)(struct git_config_backend *, const char *key, const char *regexp, git_config_foreach_cb callback, void *payload);
int (*set)(struct git_config_backend *, const char *key, const char *value);
int (*set_multivar)(git_config_backend *cfg, const char *name, const char *regexp, const char *value);
int (*del)(struct git_config_backend *, const char *key);
diff --git a/src/config.c b/src/config.c
index 6c055e0..a4627c9 100644
--- a/src/config.c
+++ b/src/config.c
@@ -574,7 +574,7 @@ int git_config_get_entry(const git_config_entry **out, const git_config *cfg, co
return config_error_notfound(name);
}
-int git_config_get_multivar(
+int git_config_get_multivar_foreach(
const git_config *cfg, const char *name, const char *regexp,
git_config_foreach_cb cb, void *payload)
{
@@ -593,7 +593,7 @@ int git_config_get_multivar(
continue;
file = internal->file;
- if (!(err = file->get_multivar(file, name, regexp, cb, payload)))
+ if (!(err = file->get_multivar_foreach(file, name, regexp, cb, payload)))
ret = 0;
else if (err != GIT_ENOTFOUND)
return err;
diff --git a/src/config_file.c b/src/config_file.c
index 6eb51ac..ed79624 100644
--- a/src/config_file.c
+++ b/src/config_file.c
@@ -413,7 +413,7 @@ static int config_get(const git_config_backend *cfg, const char *name, const git
return 0;
}
-static int config_get_multivar(
+static int config_get_multivar_foreach(
git_config_backend *cfg,
const char *name,
const char *regex_str,
@@ -603,7 +603,7 @@ int git_config_file__ondisk(git_config_backend **out, const char *path)
backend->parent.open = config_open;
backend->parent.get = config_get;
- backend->parent.get_multivar = config_get_multivar;
+ backend->parent.get_multivar_foreach = config_get_multivar_foreach;
backend->parent.set = config_set;
backend->parent.set_multivar = config_set_multivar;
backend->parent.del = config_delete;
diff --git a/src/diff_driver.c b/src/diff_driver.c
index e82dfa5..bd5a8fb 100644
--- a/src/diff_driver.c
+++ b/src/diff_driver.c
@@ -187,7 +187,7 @@ static int git_diff_driver_load(
git_buf_truncate(&name, namelen + strlen("diff.."));
git_buf_put(&name, "xfuncname", strlen("xfuncname"));
- if ((error = git_config_get_multivar(
+ if ((error = git_config_get_multivar_foreach(
cfg, name.ptr, NULL, diff_driver_xfuncname, drv)) < 0) {
if (error != GIT_ENOTFOUND)
goto done;
@@ -196,7 +196,7 @@ static int git_diff_driver_load(
git_buf_truncate(&name, namelen + strlen("diff.."));
git_buf_put(&name, "funcname", strlen("funcname"));
- if ((error = git_config_get_multivar(
+ if ((error = git_config_get_multivar_foreach(
cfg, name.ptr, NULL, diff_driver_funcname, drv)) < 0) {
if (error != GIT_ENOTFOUND)
goto done;
diff --git a/src/remote.c b/src/remote.c
index 158f3e9..003fada 100644
--- a/src/remote.c
+++ b/src/remote.c
@@ -217,7 +217,7 @@ static int get_optional_config(
return -1;
if (cb != NULL)
- error = git_config_get_multivar(config, key, NULL, cb, payload);
+ error = git_config_get_multivar_foreach(config, key, NULL, cb, payload);
else
error = git_config_get_string(payload, config, key);
diff --git a/tests-clar/config/multivar.c b/tests-clar/config/multivar.c
index efc4315..390b24c 100644
--- a/tests-clar/config/multivar.c
+++ b/tests-clar/config/multivar.c
@@ -46,27 +46,27 @@ static int cb(const git_config_entry *entry, void *data)
return 0;
}
-static void check_get_multivar(
+static void check_get_multivar_foreach(
git_config *cfg, int expected, int expected_patterned)
{
int n = 0;
if (expected > 0) {
- cl_git_pass(git_config_get_multivar(cfg, _name, NULL, cb, &n));
+ cl_git_pass(git_config_get_multivar_foreach(cfg, _name, NULL, cb, &n));
cl_assert_equal_i(expected, n);
} else {
cl_assert_equal_i(GIT_ENOTFOUND,
- git_config_get_multivar(cfg, _name, NULL, cb, &n));
+ git_config_get_multivar_foreach(cfg, _name, NULL, cb, &n));
}
n = 0;
if (expected_patterned > 0) {
- cl_git_pass(git_config_get_multivar(cfg, _name, "example", cb, &n));
+ cl_git_pass(git_config_get_multivar_foreach(cfg, _name, "example", cb, &n));
cl_assert_equal_i(expected_patterned, n);
} else {
cl_assert_equal_i(GIT_ENOTFOUND,
- git_config_get_multivar(cfg, _name, "example", cb, &n));
+ git_config_get_multivar_foreach(cfg, _name, "example", cb, &n));
}
}
@@ -75,31 +75,31 @@ void test_config_multivar__get(void)
git_config *cfg;
cl_git_pass(git_config_open_ondisk(&cfg, "config/config11"));
- check_get_multivar(cfg, 2, 1);
+ check_get_multivar_foreach(cfg, 2, 1);
/* add another that has the _name entry */
cl_git_pass(git_config_add_file_ondisk(cfg, "config/config9", GIT_CONFIG_LEVEL_SYSTEM, 1));
- check_get_multivar(cfg, 3, 2);
+ check_get_multivar_foreach(cfg, 3, 2);
/* add another that does not have the _name entry */
cl_git_pass(git_config_add_file_ondisk(cfg, "config/config0", GIT_CONFIG_LEVEL_GLOBAL, 1));
- check_get_multivar(cfg, 3, 2);
+ check_get_multivar_foreach(cfg, 3, 2);
/* add another that does not have the _name entry at the end */
cl_git_pass(git_config_add_file_ondisk(cfg, "config/config1", GIT_CONFIG_LEVEL_APP, 1));
- check_get_multivar(cfg, 3, 2);
+ check_get_multivar_foreach(cfg, 3, 2);
/* drop original file */
cl_git_pass(git_config_add_file_ondisk(cfg, "config/config2", GIT_CONFIG_LEVEL_LOCAL, 1));
- check_get_multivar(cfg, 1, 1);
+ check_get_multivar_foreach(cfg, 1, 1);
/* drop other file with match */
cl_git_pass(git_config_add_file_ondisk(cfg, "config/config3", GIT_CONFIG_LEVEL_SYSTEM, 1));
- check_get_multivar(cfg, 0, 0);
+ check_get_multivar_foreach(cfg, 0, 0);
/* reload original file (add different place in order) */
cl_git_pass(git_config_add_file_ondisk(cfg, "config/config11", GIT_CONFIG_LEVEL_SYSTEM, 1));
- check_get_multivar(cfg, 2, 1);
+ check_get_multivar_foreach(cfg, 2, 1);
git_config_free(cfg);
}
@@ -113,11 +113,11 @@ void test_config_multivar__add(void)
cl_git_pass(git_config_set_multivar(cfg, _name, "nonexistant", "git://git.otherplace.org/libgit2"));
n = 0;
- cl_git_pass(git_config_get_multivar(cfg, _name, NULL, cb, &n));
+ cl_git_pass(git_config_get_multivar_foreach(cfg, _name, NULL, cb, &n));
cl_assert(n == 3);
n = 0;
- cl_git_pass(git_config_get_multivar(cfg, _name, "otherplace", cb, &n));
+ cl_git_pass(git_config_get_multivar_foreach(cfg, _name, "otherplace", cb, &n));
cl_assert(n == 1);
git_config_free(cfg);
@@ -127,11 +127,11 @@ void test_config_multivar__add(void)
cl_git_pass(git_config_open_ondisk(&cfg, "config/config11"));
n = 0;
- cl_git_pass(git_config_get_multivar(cfg, _name, NULL, cb, &n));
+ cl_git_pass(git_config_get_multivar_foreach(cfg, _name, NULL, cb, &n));
cl_assert(n == 3);
n = 0;
- cl_git_pass(git_config_get_multivar(cfg, _name, "otherplace", cb, &n));
+ cl_git_pass(git_config_get_multivar_foreach(cfg, _name, "otherplace", cb, &n));
cl_assert(n == 1);
git_config_free(cfg);
@@ -147,7 +147,7 @@ void test_config_multivar__add_new(void)
cl_git_pass(git_config_set_multivar(cfg, var, "", "variable"));
n = 0;
- cl_git_pass(git_config_get_multivar(cfg, var, NULL, cb, &n));
+ cl_git_pass(git_config_get_multivar_foreach(cfg, var, NULL, cb, &n));
cl_assert(n == 1);
git_config_free(cfg);
@@ -161,13 +161,13 @@ void test_config_multivar__replace(void)
cl_git_pass(git_config_open_ondisk(&cfg, "config/config11"));
n = 0;
- cl_git_pass(git_config_get_multivar(cfg, _name, NULL, cb, &n));
+ cl_git_pass(git_config_get_multivar_foreach(cfg, _name, NULL, cb, &n));
cl_assert(n == 2);
cl_git_pass(git_config_set_multivar(cfg, _name, "github", "git://git.otherplace.org/libgit2"));
n = 0;
- cl_git_pass(git_config_get_multivar(cfg, _name, NULL, cb, &n));
+ cl_git_pass(git_config_get_multivar_foreach(cfg, _name, NULL, cb, &n));
cl_assert(n == 2);
git_config_free(cfg);
@@ -175,7 +175,7 @@ void test_config_multivar__replace(void)
cl_git_pass(git_config_open_ondisk(&cfg, "config/config11"));
n = 0;
- cl_git_pass(git_config_get_multivar(cfg, _name, NULL, cb, &n));
+ cl_git_pass(git_config_get_multivar_foreach(cfg, _name, NULL, cb, &n));
cl_assert(n == 2);
git_config_free(cfg);
@@ -190,7 +190,7 @@ void test_config_multivar__replace_multiple(void)
cl_git_pass(git_config_set_multivar(cfg, _name, "git://", "git://git.otherplace.org/libgit2"));
n = 0;
- cl_git_pass(git_config_get_multivar(cfg, _name, "otherplace", cb, &n));
+ cl_git_pass(git_config_get_multivar_foreach(cfg, _name, "otherplace", cb, &n));
cl_assert(n == 2);
git_config_free(cfg);
@@ -198,7 +198,7 @@ void test_config_multivar__replace_multiple(void)
cl_git_pass(git_config_open_ondisk(&cfg, "config/config11"));
n = 0;
- cl_git_pass(git_config_get_multivar(cfg, _name, "otherplace", cb, &n));
+ cl_git_pass(git_config_get_multivar_foreach(cfg, _name, "otherplace", cb, &n));
cl_assert(n == 2);
git_config_free(cfg);
diff --git a/tests-clar/config/validkeyname.c b/tests-clar/config/validkeyname.c
index 03c13d7..3369973 100644
--- a/tests-clar/config/validkeyname.c
+++ b/tests-clar/config/validkeyname.c
@@ -28,7 +28,7 @@ static void assert_invalid_config_key_name(const char *name)
GIT_EINVALIDSPEC);
cl_git_fail_with(git_config_delete_entry(cfg, name),
GIT_EINVALIDSPEC);
- cl_git_fail_with(git_config_get_multivar(cfg, name, "*", NULL, NULL),
+ cl_git_fail_with(git_config_get_multivar_foreach(cfg, name, "*", NULL, NULL),
GIT_EINVALIDSPEC);
cl_git_fail_with(git_config_set_multivar(cfg, name, "*", "42"),
GIT_EINVALIDSPEC);