@@ -56,7 +56,6 @@ struct config_source {
56
56
} u ;
57
57
enum config_origin_type origin_type ;
58
58
const char * name ;
59
- const char * path ;
60
59
enum config_error_action default_error_action ;
61
60
int linenr ;
62
61
int eof ;
@@ -173,14 +172,14 @@ static int handle_path_include(const struct key_value_info *kvi,
173
172
if (!is_absolute_path (path )) {
174
173
char * slash ;
175
174
176
- if (!kvi || ! kvi -> path ) {
175
+ if (!kvi || kvi -> origin_type != CONFIG_ORIGIN_FILE ) {
177
176
ret = error (_ ("relative config includes must come from files" ));
178
177
goto cleanup ;
179
178
}
180
179
181
- slash = find_last_dir_sep (kvi -> path );
180
+ slash = find_last_dir_sep (kvi -> filename );
182
181
if (slash )
183
- strbuf_add (& buf , kvi -> path , slash - kvi -> path + 1 );
182
+ strbuf_add (& buf , kvi -> filename , slash - kvi -> filename + 1 );
184
183
strbuf_addstr (& buf , path );
185
184
path = buf .buf ;
186
185
}
@@ -224,11 +223,11 @@ static int prepare_include_condition_pattern(const struct key_value_info *kvi,
224
223
if (pat -> buf [0 ] == '.' && is_dir_sep (pat -> buf [1 ])) {
225
224
const char * slash ;
226
225
227
- if (!kvi || ! kvi -> path )
226
+ if (!kvi || kvi -> origin_type != CONFIG_ORIGIN_FILE )
228
227
return error (_ ("relative config include "
229
228
"conditionals must come from files" ));
230
229
231
- strbuf_realpath (& path , kvi -> path , 1 );
230
+ strbuf_realpath (& path , kvi -> filename , 1 );
232
231
slash = find_last_dir_sep (path .buf );
233
232
if (!slash )
234
233
BUG ("how is this possible?" );
@@ -633,7 +632,6 @@ void kvi_from_param(struct key_value_info *out)
633
632
out -> linenr = -1 ;
634
633
out -> origin_type = CONFIG_ORIGIN_CMDLINE ;
635
634
out -> scope = CONFIG_SCOPE_COMMAND ;
636
- out -> path = NULL ;
637
635
}
638
636
639
637
int git_config_parse_parameter (const char * text ,
@@ -1036,7 +1034,6 @@ static void kvi_from_source(struct config_source *cs,
1036
1034
out -> origin_type = cs -> origin_type ;
1037
1035
out -> linenr = cs -> linenr ;
1038
1036
out -> scope = scope ;
1039
- out -> path = cs -> path ;
1040
1037
}
1041
1038
1042
1039
static 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,
1850
1847
1851
1848
static int do_config_from_file (config_fn_t fn ,
1852
1849
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 ,
1855
1852
const struct config_options * opts )
1856
1853
{
1857
1854
struct config_source top = CONFIG_SOURCE_INIT ;
1858
1855
int ret ;
1859
1856
1857
+ if (origin_type == CONFIG_ORIGIN_FILE && (!name || !* name ))
1858
+ BUG ("missing filename for CONFIG_ORIGIN_FILE" );
1859
+
1860
1860
top .u .file = f ;
1861
1861
top .origin_type = origin_type ;
1862
1862
top .name = name ;
1863
- top .path = path ;
1864
1863
top .default_error_action = CONFIG_ERROR_DIE ;
1865
1864
top .do_fgetc = config_file_fgetc ;
1866
1865
top .do_ungetc = config_file_ungetc ;
@@ -1875,8 +1874,8 @@ static int do_config_from_file(config_fn_t fn,
1875
1874
static int git_config_from_stdin (config_fn_t fn , void * data ,
1876
1875
enum config_scope scope )
1877
1876
{
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 );
1880
1879
}
1881
1880
1882
1881
int 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,
1891
1890
f = fopen_or_warn (filename , "r" );
1892
1891
if (f ) {
1893
1892
ret = do_config_from_file (fn , CONFIG_ORIGIN_FILE , filename ,
1894
- filename , f , data , scope , opts );
1893
+ f , data , scope , opts );
1895
1894
fclose (f );
1896
1895
}
1897
1896
return ret ;
@@ -1916,7 +1915,6 @@ int git_config_from_mem(config_fn_t fn,
1916
1915
top .u .buf .pos = 0 ;
1917
1916
top .origin_type = origin_type ;
1918
1917
top .name = name ;
1919
- top .path = NULL ;
1920
1918
top .default_error_action = CONFIG_ERROR_ERROR ;
1921
1919
top .do_fgetc = config_buf_fgetc ;
1922
1920
top .do_ungetc = config_buf_ungetc ;
0 commit comments