Merge branch 'gc/config-context'
Reduce reliance on a global state in the config reading API. * gc/config-context: config: pass source to config_parser_event_fn_t config: add kvi.path, use it to evaluate includes config.c: remove config_reader from configsets config: pass kvi to die_bad_number() trace2: plumb config kvi config.c: pass ctx with CLI config config: pass ctx with config files config.c: pass ctx in configsets config: add ctx arg to config_fn_t urlmatch.h: use config_fn_t type config: inline git_color_default_config
This commit is contained in:
@ -42,8 +42,11 @@
|
||||
*
|
||||
*/
|
||||
|
||||
static int iterate_cb(const char *var, const char *value, void *data UNUSED)
|
||||
static int iterate_cb(const char *var, const char *value,
|
||||
const struct config_context *ctx,
|
||||
void *data UNUSED)
|
||||
{
|
||||
const struct key_value_info *kvi = ctx->kvi;
|
||||
static int nr;
|
||||
|
||||
if (nr++)
|
||||
@ -51,26 +54,29 @@ static int iterate_cb(const char *var, const char *value, void *data UNUSED)
|
||||
|
||||
printf("key=%s\n", var);
|
||||
printf("value=%s\n", value ? value : "(null)");
|
||||
printf("origin=%s\n", current_config_origin_type());
|
||||
printf("name=%s\n", current_config_name());
|
||||
printf("lno=%d\n", current_config_line());
|
||||
printf("scope=%s\n", config_scope_name(current_config_scope()));
|
||||
printf("origin=%s\n", config_origin_type_name(kvi->origin_type));
|
||||
printf("name=%s\n", kvi->filename ? kvi->filename : "");
|
||||
printf("lno=%d\n", kvi->linenr);
|
||||
printf("scope=%s\n", config_scope_name(kvi->scope));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int parse_int_cb(const char *var, const char *value, void *data)
|
||||
static int parse_int_cb(const char *var, const char *value,
|
||||
const struct config_context *ctx, void *data)
|
||||
{
|
||||
const char *key_to_match = data;
|
||||
|
||||
if (!strcmp(key_to_match, var)) {
|
||||
int parsed = git_config_int(value, value);
|
||||
int parsed = git_config_int(value, value, ctx->kvi);
|
||||
printf("%d\n", parsed);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int early_config_cb(const char *var, const char *value, void *vdata)
|
||||
static int early_config_cb(const char *var, const char *value,
|
||||
const struct config_context *ctx UNUSED,
|
||||
void *vdata)
|
||||
{
|
||||
const char *key = vdata;
|
||||
|
||||
@ -176,7 +182,7 @@ int cmd__config(int argc, const char **argv)
|
||||
goto exit2;
|
||||
}
|
||||
}
|
||||
if (!git_configset_get_value(&cs, argv[2], &v)) {
|
||||
if (!git_configset_get_value(&cs, argv[2], &v, NULL)) {
|
||||
if (!v)
|
||||
printf("(NULL)\n");
|
||||
else
|
||||
|
@ -12,7 +12,9 @@ static int driver_cb(struct userdiff_driver *driver,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cmd__userdiff_config(const char *var, const char *value, void *cb UNUSED)
|
||||
static int cmd__userdiff_config(const char *var, const char *value,
|
||||
const struct config_context *ctx UNUSED,
|
||||
void *cb UNUSED)
|
||||
{
|
||||
if (userdiff_config(var, value) < 0)
|
||||
return -1;
|
||||
|
Reference in New Issue
Block a user