@@ -263,20 +263,20 @@ int parse_push_recurse_submodules_arg(const char *opt, const char *arg)
263
263
return parse_push_recurse (opt , arg , 1 );
264
264
}
265
265
266
- static void warn_multiple_config (const unsigned char * commit_sha1 ,
266
+ static void warn_multiple_config (const unsigned char * treeish_name ,
267
267
const char * name , const char * option )
268
268
{
269
269
const char * commit_string = "WORKTREE" ;
270
- if (commit_sha1 )
271
- commit_string = sha1_to_hex (commit_sha1 );
270
+ if (treeish_name )
271
+ commit_string = sha1_to_hex (treeish_name );
272
272
warning ("%s:.gitmodules, multiple configurations found for "
273
273
"'submodule.%s.%s'. Skipping second one!" ,
274
274
commit_string , name , option );
275
275
}
276
276
277
277
struct parse_config_parameter {
278
278
struct submodule_cache * cache ;
279
- const unsigned char * commit_sha1 ;
279
+ const unsigned char * treeish_name ;
280
280
const unsigned char * gitmodules_sha1 ;
281
281
int overwrite ;
282
282
};
@@ -300,7 +300,7 @@ static int parse_config(const char *var, const char *value, void *data)
300
300
if (!value )
301
301
ret = config_error_nonbool (var );
302
302
else if (!me -> overwrite && submodule -> path )
303
- warn_multiple_config (me -> commit_sha1 , submodule -> name ,
303
+ warn_multiple_config (me -> treeish_name , submodule -> name ,
304
304
"path" );
305
305
else {
306
306
if (submodule -> path )
@@ -314,7 +314,7 @@ static int parse_config(const char *var, const char *value, void *data)
314
314
int die_on_error = is_null_sha1 (me -> gitmodules_sha1 );
315
315
if (!me -> overwrite &&
316
316
submodule -> fetch_recurse != RECURSE_SUBMODULES_NONE )
317
- warn_multiple_config (me -> commit_sha1 , submodule -> name ,
317
+ warn_multiple_config (me -> treeish_name , submodule -> name ,
318
318
"fetchrecursesubmodules" );
319
319
else
320
320
submodule -> fetch_recurse = parse_fetch_recurse (
@@ -324,7 +324,7 @@ static int parse_config(const char *var, const char *value, void *data)
324
324
if (!value )
325
325
ret = config_error_nonbool (var );
326
326
else if (!me -> overwrite && submodule -> ignore )
327
- warn_multiple_config (me -> commit_sha1 , submodule -> name ,
327
+ warn_multiple_config (me -> treeish_name , submodule -> name ,
328
328
"ignore" );
329
329
else if (strcmp (value , "untracked" ) &&
330
330
strcmp (value , "dirty" ) &&
@@ -340,7 +340,7 @@ static int parse_config(const char *var, const char *value, void *data)
340
340
if (!value ) {
341
341
ret = config_error_nonbool (var );
342
342
} else if (!me -> overwrite && submodule -> url ) {
343
- warn_multiple_config (me -> commit_sha1 , submodule -> name ,
343
+ warn_multiple_config (me -> treeish_name , submodule -> name ,
344
344
"url" );
345
345
} else {
346
346
free ((void * ) submodule -> url );
@@ -351,21 +351,21 @@ static int parse_config(const char *var, const char *value, void *data)
351
351
ret = config_error_nonbool (var );
352
352
else if (!me -> overwrite &&
353
353
submodule -> update_strategy .type != SM_UPDATE_UNSPECIFIED )
354
- warn_multiple_config (me -> commit_sha1 , submodule -> name ,
354
+ warn_multiple_config (me -> treeish_name , submodule -> name ,
355
355
"update" );
356
356
else if (parse_submodule_update_strategy (value ,
357
357
& submodule -> update_strategy ) < 0 )
358
358
die (_ ("invalid value for %s" ), var );
359
359
} else if (!strcmp (item .buf , "shallow" )) {
360
360
if (!me -> overwrite && submodule -> recommend_shallow != -1 )
361
- warn_multiple_config (me -> commit_sha1 , submodule -> name ,
361
+ warn_multiple_config (me -> treeish_name , submodule -> name ,
362
362
"shallow" );
363
363
else
364
364
submodule -> recommend_shallow =
365
365
git_config_bool (var , value );
366
366
} else if (!strcmp (item .buf , "branch" )) {
367
367
if (!me -> overwrite && submodule -> branch )
368
- warn_multiple_config (me -> commit_sha1 , submodule -> name ,
368
+ warn_multiple_config (me -> treeish_name , submodule -> name ,
369
369
"branch" );
370
370
else {
371
371
free ((void * )submodule -> branch );
@@ -379,18 +379,18 @@ static int parse_config(const char *var, const char *value, void *data)
379
379
return ret ;
380
380
}
381
381
382
- static int gitmodule_sha1_from_commit (const unsigned char * commit_sha1 ,
382
+ static int gitmodule_sha1_from_commit (const unsigned char * treeish_name ,
383
383
unsigned char * gitmodules_sha1 ,
384
384
struct strbuf * rev )
385
385
{
386
386
int ret = 0 ;
387
387
388
- if (is_null_sha1 (commit_sha1 )) {
388
+ if (is_null_sha1 (treeish_name )) {
389
389
hashclr (gitmodules_sha1 );
390
390
return 1 ;
391
391
}
392
392
393
- strbuf_addf (rev , "%s:.gitmodules" , sha1_to_hex (commit_sha1 ));
393
+ strbuf_addf (rev , "%s:.gitmodules" , sha1_to_hex (treeish_name ));
394
394
if (get_sha1 (rev -> buf , gitmodules_sha1 ) >= 0 )
395
395
ret = 1 ;
396
396
@@ -402,7 +402,7 @@ static int gitmodule_sha1_from_commit(const unsigned char *commit_sha1,
402
402
* revisions.
403
403
*/
404
404
static const struct submodule * config_from (struct submodule_cache * cache ,
405
- const unsigned char * commit_sha1 , const char * key ,
405
+ const unsigned char * treeish_name , const char * key ,
406
406
enum lookup_type lookup_type )
407
407
{
408
408
struct strbuf rev = STRBUF_INIT ;
@@ -418,7 +418,7 @@ static const struct submodule *config_from(struct submodule_cache *cache,
418
418
* return the first submodule. Can be used to check whether
419
419
* there are any submodules parsed.
420
420
*/
421
- if (!commit_sha1 || !key ) {
421
+ if (!treeish_name || !key ) {
422
422
struct hashmap_iter iter ;
423
423
struct submodule_entry * entry ;
424
424
@@ -428,7 +428,7 @@ static const struct submodule *config_from(struct submodule_cache *cache,
428
428
return entry -> config ;
429
429
}
430
430
431
- if (!gitmodule_sha1_from_commit (commit_sha1 , sha1 , & rev ))
431
+ if (!gitmodule_sha1_from_commit (treeish_name , sha1 , & rev ))
432
432
goto out ;
433
433
434
434
switch (lookup_type ) {
@@ -448,7 +448,7 @@ static const struct submodule *config_from(struct submodule_cache *cache,
448
448
449
449
/* fill the submodule config into the cache */
450
450
parameter .cache = cache ;
451
- parameter .commit_sha1 = commit_sha1 ;
451
+ parameter .treeish_name = treeish_name ;
452
452
parameter .gitmodules_sha1 = sha1 ;
453
453
parameter .overwrite = 0 ;
454
454
git_config_from_mem (parse_config , CONFIG_ORIGIN_SUBMODULE_BLOB , rev .buf ,
@@ -471,18 +471,6 @@ static const struct submodule *config_from(struct submodule_cache *cache,
471
471
return submodule ;
472
472
}
473
473
474
- static const struct submodule * config_from_path (struct submodule_cache * cache ,
475
- const unsigned char * commit_sha1 , const char * path )
476
- {
477
- return config_from (cache , commit_sha1 , path , lookup_path );
478
- }
479
-
480
- static const struct submodule * config_from_name (struct submodule_cache * cache ,
481
- const unsigned char * commit_sha1 , const char * name )
482
- {
483
- return config_from (cache , commit_sha1 , name , lookup_name );
484
- }
485
-
486
474
static void ensure_cache_init (void )
487
475
{
488
476
if (is_cache_init )
@@ -496,26 +484,26 @@ int parse_submodule_config_option(const char *var, const char *value)
496
484
{
497
485
struct parse_config_parameter parameter ;
498
486
parameter .cache = & the_submodule_cache ;
499
- parameter .commit_sha1 = NULL ;
487
+ parameter .treeish_name = NULL ;
500
488
parameter .gitmodules_sha1 = null_sha1 ;
501
489
parameter .overwrite = 1 ;
502
490
503
491
ensure_cache_init ();
504
492
return parse_config (var , value , & parameter );
505
493
}
506
494
507
- const struct submodule * submodule_from_name (const unsigned char * commit_sha1 ,
495
+ const struct submodule * submodule_from_name (const unsigned char * treeish_name ,
508
496
const char * name )
509
497
{
510
498
ensure_cache_init ();
511
- return config_from_name (& the_submodule_cache , commit_sha1 , name );
499
+ return config_from (& the_submodule_cache , treeish_name , name , lookup_name );
512
500
}
513
501
514
- const struct submodule * submodule_from_path (const unsigned char * commit_sha1 ,
502
+ const struct submodule * submodule_from_path (const unsigned char * treeish_name ,
515
503
const char * path )
516
504
{
517
505
ensure_cache_init ();
518
- return config_from_path (& the_submodule_cache , commit_sha1 , path );
506
+ return config_from (& the_submodule_cache , treeish_name , path , lookup_path );
519
507
}
520
508
521
509
void submodule_free (void )
0 commit comments