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

@ -1410,7 +1410,8 @@ static int parse_status_slot(const char *slot)
return LOOKUP_CONFIG(color_status_slots, slot);
}
static int git_status_config(const char *k, const char *v, void *cb)
static int git_status_config(const char *k, const char *v,
const struct config_context *ctx, void *cb)
{
struct wt_status *s = cb;
const char *slot_name;
@ -1419,7 +1420,8 @@ static int git_status_config(const char *k, const char *v, void *cb)
return git_column_config(k, v, "status", &s->colopts);
if (!strcmp(k, "status.submodulesummary")) {
int is_bool;
s->submodule_summary = git_config_bool_or_int(k, v, &is_bool);
s->submodule_summary = git_config_bool_or_int(k, v, ctx->kvi,
&is_bool);
if (is_bool && s->submodule_summary)
s->submodule_summary = -1;
return 0;
@ -1479,11 +1481,11 @@ static int git_status_config(const char *k, const char *v, void *cb)
}
if (!strcmp(k, "diff.renamelimit")) {
if (s->rename_limit == -1)
s->rename_limit = git_config_int(k, v);
s->rename_limit = git_config_int(k, v, ctx->kvi);
return 0;
}
if (!strcmp(k, "status.renamelimit")) {
s->rename_limit = git_config_int(k, v);
s->rename_limit = git_config_int(k, v, ctx->kvi);
return 0;
}
if (!strcmp(k, "diff.renames")) {
@ -1495,7 +1497,7 @@ static int git_status_config(const char *k, const char *v, void *cb)
s->detect_rename = git_config_rename(k, v);
return 0;
}
return git_diff_ui_config(k, v, NULL);
return git_diff_ui_config(k, v, ctx, NULL);
}
int cmd_status(int argc, const char **argv, const char *prefix)
@ -1610,7 +1612,8 @@ int cmd_status(int argc, const char **argv, const char *prefix)
return 0;
}
static int git_commit_config(const char *k, const char *v, void *cb)
static int git_commit_config(const char *k, const char *v,
const struct config_context *ctx, void *cb)
{
struct wt_status *s = cb;
@ -1628,11 +1631,12 @@ static int git_commit_config(const char *k, const char *v, void *cb)
}
if (!strcmp(k, "commit.verbose")) {
int is_bool;
config_commit_verbose = git_config_bool_or_int(k, v, &is_bool);
config_commit_verbose = git_config_bool_or_int(k, v, ctx->kvi,
&is_bool);
return 0;
}
return git_status_config(k, v, s);
return git_status_config(k, v, ctx, s);
}
int cmd_commit(int argc, const char **argv, const char *prefix)