@@ -162,7 +162,6 @@ struct config_include_data {
162
162
const struct config_options * opts ;
163
163
struct git_config_source * config_source ;
164
164
struct repository * repo ;
165
- struct config_reader * config_reader ;
166
165
167
166
/*
168
167
* All remote URLs discovered when reading all config files.
@@ -181,8 +180,7 @@ static const char include_depth_advice[] = N_(
181
180
"from\n"
182
181
" %s\n"
183
182
"This might be due to circular includes." );
184
- static int handle_path_include (struct config_source * cs ,
185
- const struct key_value_info * kvi ,
183
+ static int handle_path_include (const struct key_value_info * kvi ,
186
184
const char * path ,
187
185
struct config_include_data * inc )
188
186
{
@@ -205,23 +203,23 @@ static int handle_path_include(struct config_source *cs,
205
203
if (!is_absolute_path (path )) {
206
204
char * slash ;
207
205
208
- if (!cs || !cs -> path ) {
206
+ if (!kvi || !kvi -> path ) {
209
207
ret = error (_ ("relative config includes must come from files" ));
210
208
goto cleanup ;
211
209
}
212
210
213
- slash = find_last_dir_sep (cs -> path );
211
+ slash = find_last_dir_sep (kvi -> path );
214
212
if (slash )
215
- strbuf_add (& buf , cs -> path , slash - cs -> path + 1 );
213
+ strbuf_add (& buf , kvi -> path , slash - kvi -> path + 1 );
216
214
strbuf_addstr (& buf , path );
217
215
path = buf .buf ;
218
216
}
219
217
220
218
if (!access_or_die (path , R_OK , 0 )) {
221
219
if (++ inc -> depth > MAX_INCLUDE_DEPTH )
222
220
die (_ (include_depth_advice ), MAX_INCLUDE_DEPTH , path ,
223
- !cs ? "<unknown>" :
224
- cs -> name ? cs -> name :
221
+ !kvi ? "<unknown>" :
222
+ kvi -> filename ? kvi -> filename :
225
223
"the command line" );
226
224
ret = git_config_from_file_with_options (git_config_include , path , inc ,
227
225
kvi -> scope , NULL );
@@ -239,7 +237,7 @@ static void add_trailing_starstar_for_dir(struct strbuf *pat)
239
237
strbuf_addstr (pat , "**" );
240
238
}
241
239
242
- static int prepare_include_condition_pattern (struct config_source * cs ,
240
+ static int prepare_include_condition_pattern (const struct key_value_info * kvi ,
243
241
struct strbuf * pat )
244
242
{
245
243
struct strbuf path = STRBUF_INIT ;
@@ -256,11 +254,11 @@ static int prepare_include_condition_pattern(struct config_source *cs,
256
254
if (pat -> buf [0 ] == '.' && is_dir_sep (pat -> buf [1 ])) {
257
255
const char * slash ;
258
256
259
- if (!cs || !cs -> path )
257
+ if (!kvi || !kvi -> path )
260
258
return error (_ ("relative config include "
261
259
"conditionals must come from files" ));
262
260
263
- strbuf_realpath (& path , cs -> path , 1 );
261
+ strbuf_realpath (& path , kvi -> path , 1 );
264
262
slash = find_last_dir_sep (path .buf );
265
263
if (!slash )
266
264
BUG ("how is this possible?" );
@@ -275,7 +273,7 @@ static int prepare_include_condition_pattern(struct config_source *cs,
275
273
return prefix ;
276
274
}
277
275
278
- static int include_by_gitdir (struct config_source * cs ,
276
+ static int include_by_gitdir (const struct key_value_info * kvi ,
279
277
const struct config_options * opts ,
280
278
const char * cond , size_t cond_len , int icase )
281
279
{
@@ -292,7 +290,7 @@ static int include_by_gitdir(struct config_source *cs,
292
290
293
291
strbuf_realpath (& text , git_dir , 1 );
294
292
strbuf_add (& pattern , cond , cond_len );
295
- prefix = prepare_include_condition_pattern (cs , & pattern );
293
+ prefix = prepare_include_condition_pattern (kvi , & pattern );
296
294
297
295
again :
298
296
if (prefix < 0 )
@@ -428,16 +426,16 @@ static int include_by_remote_url(struct config_include_data *inc,
428
426
inc -> remote_urls );
429
427
}
430
428
431
- static int include_condition_is_true (struct config_source * cs ,
429
+ static int include_condition_is_true (const struct key_value_info * kvi ,
432
430
struct config_include_data * inc ,
433
431
const char * cond , size_t cond_len )
434
432
{
435
433
const struct config_options * opts = inc -> opts ;
436
434
437
435
if (skip_prefix_mem (cond , cond_len , "gitdir:" , & cond , & cond_len ))
438
- return include_by_gitdir (cs , opts , cond , cond_len , 0 );
436
+ return include_by_gitdir (kvi , opts , cond , cond_len , 0 );
439
437
else if (skip_prefix_mem (cond , cond_len , "gitdir/i:" , & cond , & cond_len ))
440
- return include_by_gitdir (cs , opts , cond , cond_len , 1 );
438
+ return include_by_gitdir (kvi , opts , cond , cond_len , 1 );
441
439
else if (skip_prefix_mem (cond , cond_len , "onbranch:" , & cond , & cond_len ))
442
440
return include_by_branch (cond , cond_len );
443
441
else if (skip_prefix_mem (cond , cond_len , "hasconfig:remote.*.url:" , & cond ,
@@ -453,7 +451,6 @@ static int git_config_include(const char *var, const char *value,
453
451
void * data )
454
452
{
455
453
struct config_include_data * inc = data ;
456
- struct config_source * cs = inc -> config_reader -> source ;
457
454
const char * cond , * key ;
458
455
size_t cond_len ;
459
456
int ret ;
@@ -467,16 +464,16 @@ static int git_config_include(const char *var, const char *value,
467
464
return ret ;
468
465
469
466
if (!strcmp (var , "include.path" ))
470
- ret = handle_path_include (cs , ctx -> kvi , value , inc );
467
+ ret = handle_path_include (ctx -> kvi , value , inc );
471
468
472
469
if (!parse_config_key (var , "includeif" , & cond , & cond_len , & key ) &&
473
- cond && include_condition_is_true (cs , inc , cond , cond_len ) &&
470
+ cond && include_condition_is_true (ctx -> kvi , inc , cond , cond_len ) &&
474
471
!strcmp (key , "path" )) {
475
472
config_fn_t old_fn = inc -> fn ;
476
473
477
474
if (inc -> opts -> unconditional_remote_url )
478
475
inc -> fn = forbid_remote_url ;
479
- ret = handle_path_include (cs , ctx -> kvi , value , inc );
476
+ ret = handle_path_include (ctx -> kvi , value , inc );
480
477
inc -> fn = old_fn ;
481
478
}
482
479
@@ -661,6 +658,7 @@ void kvi_from_param(struct key_value_info *out)
661
658
out -> linenr = -1 ;
662
659
out -> origin_type = CONFIG_ORIGIN_CMDLINE ;
663
660
out -> scope = CONFIG_SCOPE_COMMAND ;
661
+ out -> path = NULL ;
664
662
}
665
663
666
664
int git_config_parse_parameter (const char * text ,
@@ -1064,6 +1062,7 @@ static void kvi_from_source(struct config_source *cs,
1064
1062
out -> origin_type = cs -> origin_type ;
1065
1063
out -> linenr = cs -> linenr ;
1066
1064
out -> scope = scope ;
1065
+ out -> path = cs -> path ;
1067
1066
}
1068
1067
1069
1068
static int git_parse_source (struct config_source * cs , config_fn_t fn ,
@@ -2282,7 +2281,6 @@ int config_with_options(config_fn_t fn, void *data,
2282
2281
inc .opts = opts ;
2283
2282
inc .repo = repo ;
2284
2283
inc .config_source = config_source ;
2285
- inc .config_reader = & the_reader ;
2286
2284
fn = git_config_include ;
2287
2285
data = & inc ;
2288
2286
}
0 commit comments