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:
Junio C Hamano
2023-07-06 11:54:48 -07:00
103 changed files with 960 additions and 632 deletions

View File

@ -269,6 +269,7 @@ static const char *abbrev_ref(const char *name, const char *prefix)
#define abbrev_branch(name) abbrev_ref((name), "refs/heads/")
static int config_read_branches(const char *key, const char *value,
const struct config_context *ctx UNUSED,
void *data UNUSED)
{
const char *orig_key = key;
@ -646,17 +647,19 @@ struct push_default_info
};
static int config_read_push_default(const char *key, const char *value,
void *cb)
const struct config_context *ctx, void *cb)
{
const struct key_value_info *kvi = ctx->kvi;
struct push_default_info* info = cb;
if (strcmp(key, "remote.pushdefault") ||
!value || strcmp(value, info->old_name))
return 0;
info->scope = current_config_scope();
info->scope = kvi->scope;
strbuf_reset(&info->origin);
strbuf_addstr(&info->origin, current_config_name());
info->linenr = current_config_line();
strbuf_addstr(&info->origin, config_origin_type_name(kvi->origin_type));
info->linenr = kvi->linenr;
return 0;
}
@ -1495,7 +1498,9 @@ static int prune(int argc, const char **argv, const char *prefix)
return result;
}
static int get_remote_default(const char *key, const char *value UNUSED, void *priv)
static int get_remote_default(const char *key, const char *value UNUSED,
const struct config_context *ctx UNUSED,
void *priv)
{
if (strcmp(key, "remotes.default") == 0) {
int *found = priv;