@@ -162,7 +162,6 @@ struct config_include_data {
162162 const struct config_options * opts ;
163163 struct git_config_source * config_source ;
164164 struct repository * repo ;
165- struct config_reader * config_reader ;
166165
167166 /*
168167 * All remote URLs discovered when reading all config files.
@@ -181,8 +180,7 @@ static const char include_depth_advice[] = N_(
181180"from\n"
182181" %s\n"
183182"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 ,
186184 const char * path ,
187185 struct config_include_data * inc )
188186{
@@ -205,23 +203,23 @@ static int handle_path_include(struct config_source *cs,
205203 if (!is_absolute_path (path )) {
206204 char * slash ;
207205
208- if (!cs || !cs -> path ) {
206+ if (!kvi || !kvi -> path ) {
209207 ret = error (_ ("relative config includes must come from files" ));
210208 goto cleanup ;
211209 }
212210
213- slash = find_last_dir_sep (cs -> path );
211+ slash = find_last_dir_sep (kvi -> path );
214212 if (slash )
215- strbuf_add (& buf , cs -> path , slash - cs -> path + 1 );
213+ strbuf_add (& buf , kvi -> path , slash - kvi -> path + 1 );
216214 strbuf_addstr (& buf , path );
217215 path = buf .buf ;
218216 }
219217
220218 if (!access_or_die (path , R_OK , 0 )) {
221219 if (++ inc -> depth > MAX_INCLUDE_DEPTH )
222220 die (_ (include_depth_advice ), MAX_INCLUDE_DEPTH , path ,
223- !cs ? "<unknown>" :
224- cs -> name ? cs -> name :
221+ !kvi ? "<unknown>" :
222+ kvi -> filename ? kvi -> filename :
225223 "the command line" );
226224 ret = git_config_from_file_with_options (git_config_include , path , inc ,
227225 kvi -> scope , NULL );
@@ -239,7 +237,7 @@ static void add_trailing_starstar_for_dir(struct strbuf *pat)
239237 strbuf_addstr (pat , "**" );
240238}
241239
242- static int prepare_include_condition_pattern (struct config_source * cs ,
240+ static int prepare_include_condition_pattern (const struct key_value_info * kvi ,
243241 struct strbuf * pat )
244242{
245243 struct strbuf path = STRBUF_INIT ;
@@ -256,11 +254,11 @@ static int prepare_include_condition_pattern(struct config_source *cs,
256254 if (pat -> buf [0 ] == '.' && is_dir_sep (pat -> buf [1 ])) {
257255 const char * slash ;
258256
259- if (!cs || !cs -> path )
257+ if (!kvi || !kvi -> path )
260258 return error (_ ("relative config include "
261259 "conditionals must come from files" ));
262260
263- strbuf_realpath (& path , cs -> path , 1 );
261+ strbuf_realpath (& path , kvi -> path , 1 );
264262 slash = find_last_dir_sep (path .buf );
265263 if (!slash )
266264 BUG ("how is this possible?" );
@@ -275,7 +273,7 @@ static int prepare_include_condition_pattern(struct config_source *cs,
275273 return prefix ;
276274}
277275
278- static int include_by_gitdir (struct config_source * cs ,
276+ static int include_by_gitdir (const struct key_value_info * kvi ,
279277 const struct config_options * opts ,
280278 const char * cond , size_t cond_len , int icase )
281279{
@@ -292,7 +290,7 @@ static int include_by_gitdir(struct config_source *cs,
292290
293291 strbuf_realpath (& text , git_dir , 1 );
294292 strbuf_add (& pattern , cond , cond_len );
295- prefix = prepare_include_condition_pattern (cs , & pattern );
293+ prefix = prepare_include_condition_pattern (kvi , & pattern );
296294
297295again :
298296 if (prefix < 0 )
@@ -428,16 +426,16 @@ static int include_by_remote_url(struct config_include_data *inc,
428426 inc -> remote_urls );
429427}
430428
431- static int include_condition_is_true (struct config_source * cs ,
429+ static int include_condition_is_true (const struct key_value_info * kvi ,
432430 struct config_include_data * inc ,
433431 const char * cond , size_t cond_len )
434432{
435433 const struct config_options * opts = inc -> opts ;
436434
437435 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 );
439437 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 );
441439 else if (skip_prefix_mem (cond , cond_len , "onbranch:" , & cond , & cond_len ))
442440 return include_by_branch (cond , cond_len );
443441 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,
453451 void * data )
454452{
455453 struct config_include_data * inc = data ;
456- struct config_source * cs = inc -> config_reader -> source ;
457454 const char * cond , * key ;
458455 size_t cond_len ;
459456 int ret ;
@@ -467,16 +464,16 @@ static int git_config_include(const char *var, const char *value,
467464 return ret ;
468465
469466 if (!strcmp (var , "include.path" ))
470- ret = handle_path_include (cs , ctx -> kvi , value , inc );
467+ ret = handle_path_include (ctx -> kvi , value , inc );
471468
472469 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 ) &&
474471 !strcmp (key , "path" )) {
475472 config_fn_t old_fn = inc -> fn ;
476473
477474 if (inc -> opts -> unconditional_remote_url )
478475 inc -> fn = forbid_remote_url ;
479- ret = handle_path_include (cs , ctx -> kvi , value , inc );
476+ ret = handle_path_include (ctx -> kvi , value , inc );
480477 inc -> fn = old_fn ;
481478 }
482479
@@ -661,6 +658,7 @@ void kvi_from_param(struct key_value_info *out)
661658 out -> linenr = -1 ;
662659 out -> origin_type = CONFIG_ORIGIN_CMDLINE ;
663660 out -> scope = CONFIG_SCOPE_COMMAND ;
661+ out -> path = NULL ;
664662}
665663
666664int git_config_parse_parameter (const char * text ,
@@ -1064,6 +1062,7 @@ static void kvi_from_source(struct config_source *cs,
10641062 out -> origin_type = cs -> origin_type ;
10651063 out -> linenr = cs -> linenr ;
10661064 out -> scope = scope ;
1065+ out -> path = cs -> path ;
10671066}
10681067
10691068static 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,
22822281 inc .opts = opts ;
22832282 inc .repo = repo ;
22842283 inc .config_source = config_source ;
2285- inc .config_reader = & the_reader ;
22862284 fn = git_config_include ;
22872285 data = & inc ;
22882286 }
0 commit comments