@@ -33,7 +33,7 @@ static void attr_file_free(git_attr_file *file)
3333int git_attr_file__new (
3434 git_attr_file * * out ,
3535 git_attr_file_entry * entry ,
36- git_attr_file_source_t source_type )
36+ git_attr_file_source * source )
3737{
3838 git_attr_file * attrs = git__calloc (1 , sizeof (git_attr_file ));
3939 GIT_ERROR_CHECK_ALLOC (attrs );
@@ -48,7 +48,7 @@ int git_attr_file__new(
4848
4949 GIT_REFCOUNT_INC (attrs );
5050 attrs -> entry = entry ;
51- attrs -> source_type = source_type ;
51+ memcpy ( & attrs -> source , source , sizeof ( git_attr_file_source )) ;
5252 * out = attrs ;
5353 return 0 ;
5454
@@ -108,7 +108,7 @@ int git_attr_file__load(
108108 git_repository * repo ,
109109 git_attr_session * attr_session ,
110110 git_attr_file_entry * entry ,
111- git_attr_file_source_t source_type ,
111+ git_attr_file_source * source ,
112112 git_attr_file_parser parser ,
113113 bool allow_macros )
114114{
@@ -128,7 +128,7 @@ int git_attr_file__load(
128128
129129 * out = NULL ;
130130
131- switch (source_type ) {
131+ switch (source -> type ) {
132132 case GIT_ATTR_FILE_SOURCE_MEMORY :
133133 /* in-memory attribute file doesn't need data */
134134 break ;
@@ -182,11 +182,11 @@ int git_attr_file__load(
182182 break ;
183183 }
184184 default :
185- git_error_set (GIT_ERROR_INVALID , "unknown file source %d" , source_type );
185+ git_error_set (GIT_ERROR_INVALID , "unknown file source %d" , source -> type );
186186 return -1 ;
187187 }
188188
189- if ((error = git_attr_file__new (& file , entry , source_type )) < 0 )
189+ if ((error = git_attr_file__new (& file , entry , source )) < 0 )
190190 goto cleanup ;
191191
192192 /* advance over a UTF8 BOM */
@@ -210,11 +210,11 @@ int git_attr_file__load(
210210 /* write cache breakers */
211211 if (nonexistent )
212212 file -> nonexistent = 1 ;
213- else if (source_type == GIT_ATTR_FILE_SOURCE_INDEX )
213+ else if (source -> type == GIT_ATTR_FILE_SOURCE_INDEX )
214214 git_oid_cpy (& file -> cache_data .oid , git_blob_id (blob ));
215- else if (source_type == GIT_ATTR_FILE_SOURCE_HEAD )
215+ else if (source -> type == GIT_ATTR_FILE_SOURCE_HEAD )
216216 git_oid_cpy (& file -> cache_data .oid , git_tree_id (tree ));
217- else if (source_type == GIT_ATTR_FILE_SOURCE_FILE )
217+ else if (source -> type == GIT_ATTR_FILE_SOURCE_FILE )
218218 git_futils_filestamp_set_from_stat (& file -> cache_data .stamp , & st );
219219 /* else always cacheable */
220220
@@ -245,7 +245,7 @@ int git_attr_file__out_of_date(
245245 else if (file -> nonexistent )
246246 return 1 ;
247247
248- switch (file -> source_type ) {
248+ switch (file -> source . type ) {
249249 case GIT_ATTR_FILE_SOURCE_MEMORY :
250250 return 0 ;
251251
@@ -278,7 +278,7 @@ int git_attr_file__out_of_date(
278278 }
279279
280280 default :
281- git_error_set (GIT_ERROR_INVALID , "invalid file type %d" , file -> source_type );
281+ git_error_set (GIT_ERROR_INVALID , "invalid file type %d" , file -> source . type );
282282 return -1 ;
283283 }
284284}
@@ -389,6 +389,7 @@ int git_attr_file__lookup_one(
389389int git_attr_file__load_standalone (git_attr_file * * out , const char * path )
390390{
391391 git_buf content = GIT_BUF_INIT ;
392+ git_attr_file_source source = { GIT_ATTR_FILE_SOURCE_FILE };
392393 git_attr_file * file = NULL ;
393394 int error ;
394395
@@ -400,7 +401,7 @@ int git_attr_file__load_standalone(git_attr_file **out, const char *path)
400401 * don't have to free it - freeing file+pool will free cache entry, too.
401402 */
402403
403- if ((error = git_attr_file__new (& file , NULL , GIT_ATTR_FILE_SOURCE_FILE )) < 0 ||
404+ if ((error = git_attr_file__new (& file , NULL , & source )) < 0 ||
404405 (error = git_attr_file__parse_buffer (NULL , file , content .ptr , true)) < 0 ||
405406 (error = git_attr_cache__alloc_file_entry (& file -> entry , NULL , NULL , path , & file -> pool )) < 0 )
406407 goto out ;
0 commit comments