Merge branch 'gc/config-context' into next

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-06-28 23:04:42 -07:00
103 changed files with 960 additions and 632 deletions

View File

@ -350,7 +350,8 @@ static void read_branches_file(struct remote_state *remote_state,
remote->fetch_tags = 1; /* always auto-follow */
}
static int handle_config(const char *key, const char *value, void *cb)
static int handle_config(const char *key, const char *value,
const struct config_context *ctx, void *cb)
{
const char *name;
size_t namelen;
@ -358,6 +359,7 @@ static int handle_config(const char *key, const char *value, void *cb)
struct remote *remote;
struct branch *branch;
struct remote_state *remote_state = cb;
const struct key_value_info *kvi = ctx->kvi;
if (parse_config_key(key, "branch", &name, &namelen, &subkey) >= 0) {
/* There is no subsection. */
@ -415,8 +417,8 @@ static int handle_config(const char *key, const char *value, void *cb)
}
remote = make_remote(remote_state, name, namelen);
remote->origin = REMOTE_CONFIG;
if (current_config_scope() == CONFIG_SCOPE_LOCAL ||
current_config_scope() == CONFIG_SCOPE_WORKTREE)
if (kvi->scope == CONFIG_SCOPE_LOCAL ||
kvi->scope == CONFIG_SCOPE_WORKTREE)
remote->configured_in_repo = 1;
if (!strcmp(subkey, "mirror"))
remote->mirror = git_config_bool(key, value);