Skip to content

Commit b3d1c85

Browse files
committed
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
2 parents 1d76e69 + 6e8e798 commit b3d1c85

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+960
-632
lines changed

alias.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ struct config_alias_data {
1212
struct string_list *list;
1313
};
1414

15-
static int config_alias_cb(const char *key, const char *value, void *d)
15+
static int config_alias_cb(const char *key, const char *value,
16+
const struct config_context *ctx UNUSED, void *d)
1617
{
1718
struct config_alias_data *data = d;
1819
const char *p;

archive-tar.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -411,14 +411,15 @@ static int tar_filter_config(const char *var, const char *value,
411411
return 0;
412412
}
413413

414-
static int git_tar_config(const char *var, const char *value, void *cb)
414+
static int git_tar_config(const char *var, const char *value,
415+
const struct config_context *ctx, void *cb)
415416
{
416417
if (!strcmp(var, "tar.umask")) {
417418
if (value && !strcmp(value, "user")) {
418419
tar_umask = umask(0);
419420
umask(tar_umask);
420421
} else {
421-
tar_umask = git_config_int(var, value);
422+
tar_umask = git_config_int(var, value, ctx->kvi);
422423
}
423424
return 0;
424425
}

archive-zip.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,7 @@ static void dos_time(timestamp_t *timestamp, int *dos_date, int *dos_time)
617617
}
618618

619619
static int archive_zip_config(const char *var, const char *value,
620+
const struct config_context *ctx UNUSED,
620621
void *data UNUSED)
621622
{
622623
return userdiff_config(var, value);

builtin/add.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -266,15 +266,19 @@ static struct option builtin_add_options[] = {
266266
OPT_END(),
267267
};
268268

269-
static int add_config(const char *var, const char *value, void *cb)
269+
static int add_config(const char *var, const char *value,
270+
const struct config_context *ctx, void *cb)
270271
{
271272
if (!strcmp(var, "add.ignoreerrors") ||
272273
!strcmp(var, "add.ignore-errors")) {
273274
ignore_add_errors = git_config_bool(var, value);
274275
return 0;
275276
}
276277

277-
return git_color_default_config(var, value, cb);
278+
if (git_color_config(var, value, cb) < 0)
279+
return -1;
280+
281+
return git_default_config(var, value, ctx, cb);
278282
}
279283

280284
static const char embedded_advice[] = N_(

builtin/blame.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -694,7 +694,8 @@ static const char *add_prefix(const char *prefix, const char *path)
694694
return prefix_path(prefix, prefix ? strlen(prefix) : 0, path);
695695
}
696696

697-
static int git_blame_config(const char *var, const char *value, void *cb)
697+
static int git_blame_config(const char *var, const char *value,
698+
const struct config_context *ctx, void *cb)
698699
{
699700
if (!strcmp(var, "blame.showroot")) {
700701
show_root = git_config_bool(var, value);
@@ -767,7 +768,7 @@ static int git_blame_config(const char *var, const char *value, void *cb)
767768
if (userdiff_config(var, value) < 0)
768769
return -1;
769770

770-
return git_default_config(var, value, cb);
771+
return git_default_config(var, value, ctx, cb);
771772
}
772773

773774
static int blame_copy_callback(const struct option *option, const char *arg, int unset)

builtin/branch.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@ static unsigned int colopts;
8383

8484
define_list_config_array(color_branch_slots);
8585

86-
static int git_branch_config(const char *var, const char *value, void *cb)
86+
static int git_branch_config(const char *var, const char *value,
87+
const struct config_context *ctx, void *cb)
8788
{
8889
const char *slot_name;
8990

@@ -117,7 +118,10 @@ static int git_branch_config(const char *var, const char *value, void *cb)
117118
return 0;
118119
}
119120

120-
return git_color_default_config(var, value, cb);
121+
if (git_color_config(var, value, cb) < 0)
122+
return -1;
123+
124+
return git_default_config(var, value, ctx, cb);
121125
}
122126

123127
static const char *branch_get_color(enum color_branch ix)

builtin/cat-file.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -871,12 +871,13 @@ static int batch_objects(struct batch_options *opt)
871871
return retval;
872872
}
873873

874-
static int git_cat_file_config(const char *var, const char *value, void *cb)
874+
static int git_cat_file_config(const char *var, const char *value,
875+
const struct config_context *ctx, void *cb)
875876
{
876877
if (userdiff_config(var, value) < 0)
877878
return -1;
878879

879-
return git_default_config(var, value, cb);
880+
return git_default_config(var, value, ctx, cb);
880881
}
881882

882883
static int batch_option_callback(const struct option *opt,

builtin/checkout.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1189,7 +1189,8 @@ static int switch_branches(const struct checkout_opts *opts,
11891189
return ret || writeout_error;
11901190
}
11911191

1192-
static int git_checkout_config(const char *var, const char *value, void *cb)
1192+
static int git_checkout_config(const char *var, const char *value,
1193+
const struct config_context *ctx, void *cb)
11931194
{
11941195
struct checkout_opts *opts = cb;
11951196

@@ -1205,7 +1206,7 @@ static int git_checkout_config(const char *var, const char *value, void *cb)
12051206
if (starts_with(var, "submodule."))
12061207
return git_default_submodule_config(var, value, NULL);
12071208

1208-
return git_xmerge_config(var, value, NULL);
1209+
return git_xmerge_config(var, value, ctx, NULL);
12091210
}
12101211

12111212
static void setup_new_branch_info_and_source_tree(
@@ -1692,8 +1693,13 @@ static int checkout_main(int argc, const char **argv, const char *prefix,
16921693
}
16931694

16941695
if (opts->conflict_style) {
1696+
struct key_value_info kvi = KVI_INIT;
1697+
struct config_context ctx = {
1698+
.kvi = &kvi,
1699+
};
16951700
opts->merge = 1; /* implied */
1696-
git_xmerge_config("merge.conflictstyle", opts->conflict_style, NULL);
1701+
git_xmerge_config("merge.conflictstyle", opts->conflict_style,
1702+
&ctx, NULL);
16971703
}
16981704
if (opts->force) {
16991705
opts->discard_changes = 1;

builtin/clean.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ struct menu_stuff {
104104

105105
define_list_config_array(color_interactive_slots);
106106

107-
static int git_clean_config(const char *var, const char *value, void *cb)
107+
static int git_clean_config(const char *var, const char *value,
108+
const struct config_context *ctx, void *cb)
108109
{
109110
const char *slot_name;
110111

@@ -131,8 +132,10 @@ static int git_clean_config(const char *var, const char *value, void *cb)
131132
return 0;
132133
}
133134

134-
/* inspect the color.ui config variable and others */
135-
return git_color_default_config(var, value, cb);
135+
if (git_color_config(var, value, cb) < 0)
136+
return -1;
137+
138+
return git_default_config(var, value, ctx, cb);
136139
}
137140

138141
static const char *clean_get_color(enum color_clean ix)

builtin/clone.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,8 @@ static int checkout(int submodule_progress, int filter_submodules)
791791
return err;
792792
}
793793

794-
static int git_clone_config(const char *k, const char *v, void *cb)
794+
static int git_clone_config(const char *k, const char *v,
795+
const struct config_context *ctx, void *cb)
795796
{
796797
if (!strcmp(k, "clone.defaultremotename")) {
797798
free(remote_name);
@@ -802,17 +803,19 @@ static int git_clone_config(const char *k, const char *v, void *cb)
802803
if (!strcmp(k, "clone.filtersubmodules"))
803804
config_filter_submodules = git_config_bool(k, v);
804805

805-
return git_default_config(k, v, cb);
806+
return git_default_config(k, v, ctx, cb);
806807
}
807808

808-
static int write_one_config(const char *key, const char *value, void *data)
809+
static int write_one_config(const char *key, const char *value,
810+
const struct config_context *ctx,
811+
void *data)
809812
{
810813
/*
811814
* give git_clone_config a chance to write config values back to the
812815
* environment, since git_config_set_multivar_gently only deals with
813816
* config-file writes
814817
*/
815-
int apply_failed = git_clone_config(key, value, data);
818+
int apply_failed = git_clone_config(key, value, ctx, data);
816819
if (apply_failed)
817820
return apply_failed;
818821

0 commit comments

Comments
 (0)