@@ -56,7 +56,6 @@ struct config_source {
5656 } u ;
5757 enum config_origin_type origin_type ;
5858 const char * name ;
59- const char * path ;
6059 enum config_error_action default_error_action ;
6160 int linenr ;
6261 int eof ;
@@ -173,14 +172,14 @@ static int handle_path_include(const struct key_value_info *kvi,
173172 if (!is_absolute_path (path )) {
174173 char * slash ;
175174
176- if (!kvi || ! kvi -> path ) {
175+ if (!kvi || kvi -> origin_type != CONFIG_ORIGIN_FILE ) {
177176 ret = error (_ ("relative config includes must come from files" ));
178177 goto cleanup ;
179178 }
180179
181- slash = find_last_dir_sep (kvi -> path );
180+ slash = find_last_dir_sep (kvi -> filename );
182181 if (slash )
183- strbuf_add (& buf , kvi -> path , slash - kvi -> path + 1 );
182+ strbuf_add (& buf , kvi -> filename , slash - kvi -> filename + 1 );
184183 strbuf_addstr (& buf , path );
185184 path = buf .buf ;
186185 }
@@ -224,11 +223,11 @@ static int prepare_include_condition_pattern(const struct key_value_info *kvi,
224223 if (pat -> buf [0 ] == '.' && is_dir_sep (pat -> buf [1 ])) {
225224 const char * slash ;
226225
227- if (!kvi || ! kvi -> path )
226+ if (!kvi || kvi -> origin_type != CONFIG_ORIGIN_FILE )
228227 return error (_ ("relative config include "
229228 "conditionals must come from files" ));
230229
231- strbuf_realpath (& path , kvi -> path , 1 );
230+ strbuf_realpath (& path , kvi -> filename , 1 );
232231 slash = find_last_dir_sep (path .buf );
233232 if (!slash )
234233 BUG ("how is this possible?" );
@@ -633,7 +632,6 @@ void kvi_from_param(struct key_value_info *out)
633632 out -> linenr = -1 ;
634633 out -> origin_type = CONFIG_ORIGIN_CMDLINE ;
635634 out -> scope = CONFIG_SCOPE_COMMAND ;
636- out -> path = NULL ;
637635}
638636
639637int git_config_parse_parameter (const char * text ,
@@ -1036,7 +1034,6 @@ static void kvi_from_source(struct config_source *cs,
10361034 out -> origin_type = cs -> origin_type ;
10371035 out -> linenr = cs -> linenr ;
10381036 out -> scope = scope ;
1039- out -> path = cs -> path ;
10401037}
10411038
10421039static int git_parse_source (struct config_source * cs , config_fn_t fn ,
@@ -1850,17 +1847,19 @@ static int do_config_from(struct config_source *top, config_fn_t fn,
18501847
18511848static int do_config_from_file (config_fn_t fn ,
18521849 const enum config_origin_type origin_type ,
1853- const char * name , const char * path , FILE * f ,
1854- void * data , enum config_scope scope ,
1850+ const char * name , FILE * f , void * data ,
1851+ enum config_scope scope ,
18551852 const struct config_options * opts )
18561853{
18571854 struct config_source top = CONFIG_SOURCE_INIT ;
18581855 int ret ;
18591856
1857+ if (origin_type == CONFIG_ORIGIN_FILE && (!name || !* name ))
1858+ BUG ("missing filename for CONFIG_ORIGIN_FILE" );
1859+
18601860 top .u .file = f ;
18611861 top .origin_type = origin_type ;
18621862 top .name = name ;
1863- top .path = path ;
18641863 top .default_error_action = CONFIG_ERROR_DIE ;
18651864 top .do_fgetc = config_file_fgetc ;
18661865 top .do_ungetc = config_file_ungetc ;
@@ -1875,8 +1874,8 @@ static int do_config_from_file(config_fn_t fn,
18751874static int git_config_from_stdin (config_fn_t fn , void * data ,
18761875 enum config_scope scope )
18771876{
1878- return do_config_from_file (fn , CONFIG_ORIGIN_STDIN , "" , NULL , stdin ,
1879- data , scope , NULL );
1877+ return do_config_from_file (fn , CONFIG_ORIGIN_STDIN , "" , stdin , data ,
1878+ scope , NULL );
18801879}
18811880
18821881int git_config_from_file_with_options (config_fn_t fn , const char * filename ,
@@ -1891,7 +1890,7 @@ int git_config_from_file_with_options(config_fn_t fn, const char *filename,
18911890 f = fopen_or_warn (filename , "r" );
18921891 if (f ) {
18931892 ret = do_config_from_file (fn , CONFIG_ORIGIN_FILE , filename ,
1894- filename , f , data , scope , opts );
1893+ f , data , scope , opts );
18951894 fclose (f );
18961895 }
18971896 return ret ;
@@ -1916,7 +1915,6 @@ int git_config_from_mem(config_fn_t fn,
19161915 top .u .buf .pos = 0 ;
19171916 top .origin_type = origin_type ;
19181917 top .name = name ;
1919- top .path = NULL ;
19201918 top .default_error_action = CONFIG_ERROR_ERROR ;
19211919 top .do_fgetc = config_buf_fgetc ;
19221920 top .do_ungetc = config_buf_ungetc ;
0 commit comments