@@ -379,7 +379,7 @@ static void runcommand_in_submodule_cb(const struct cache_entry *list_item,
379
379
static int module_foreach (int argc , const char * * argv , const char * prefix )
380
380
{
381
381
struct foreach_cb info = FOREACH_CB_INIT ;
382
- struct pathspec pathspec ;
382
+ struct pathspec pathspec = { 0 } ;
383
383
struct module_list list = MODULE_LIST_INIT ;
384
384
struct option module_foreach_options [] = {
385
385
OPT__QUIET (& info .quiet , N_ ("suppress output of entering each submodule command" )),
@@ -391,20 +391,24 @@ static int module_foreach(int argc, const char **argv, const char *prefix)
391
391
N_ ("git submodule foreach [--quiet] [--recursive] [--] <command>" ),
392
392
NULL
393
393
};
394
+ int ret = 1 ;
394
395
395
396
argc = parse_options (argc , argv , prefix , module_foreach_options ,
396
397
git_submodule_helper_usage , 0 );
397
398
398
399
if (module_list_compute (0 , NULL , prefix , & pathspec , & list ) < 0 )
399
- return 1 ;
400
+ goto cleanup ;
400
401
401
402
info .argc = argc ;
402
403
info .argv = argv ;
403
404
info .prefix = prefix ;
404
405
405
406
for_each_listed_submodule (& list , runcommand_in_submodule_cb , & info );
406
407
407
- return 0 ;
408
+ ret = 0 ;
409
+ cleanup :
410
+ clear_pathspec (& pathspec );
411
+ return ret ;
408
412
}
409
413
410
414
static int starts_with_dot_slash (const char * const path )
@@ -515,7 +519,7 @@ static void init_submodule_cb(const struct cache_entry *list_item, void *cb_data
515
519
static int module_init (int argc , const char * * argv , const char * prefix )
516
520
{
517
521
struct init_cb info = INIT_CB_INIT ;
518
- struct pathspec pathspec ;
522
+ struct pathspec pathspec = { 0 } ;
519
523
struct module_list list = MODULE_LIST_INIT ;
520
524
int quiet = 0 ;
521
525
struct option module_init_options [] = {
@@ -526,12 +530,13 @@ static int module_init(int argc, const char **argv, const char *prefix)
526
530
N_ ("git submodule init [<options>] [<path>]" ),
527
531
NULL
528
532
};
533
+ int ret = 1 ;
529
534
530
535
argc = parse_options (argc , argv , prefix , module_init_options ,
531
536
git_submodule_helper_usage , 0 );
532
537
533
538
if (module_list_compute (argc , argv , prefix , & pathspec , & list ) < 0 )
534
- return 1 ;
539
+ goto cleanup ;
535
540
536
541
/*
537
542
* If there are no path args and submodule.active is set then,
@@ -546,7 +551,10 @@ static int module_init(int argc, const char **argv, const char *prefix)
546
551
547
552
for_each_listed_submodule (& list , init_submodule_cb , & info );
548
553
549
- return 0 ;
554
+ ret = 0 ;
555
+ cleanup :
556
+ clear_pathspec (& pathspec );
557
+ return ret ;
550
558
}
551
559
552
560
struct status_cb {
@@ -693,7 +701,7 @@ static void status_submodule_cb(const struct cache_entry *list_item,
693
701
static int module_status (int argc , const char * * argv , const char * prefix )
694
702
{
695
703
struct status_cb info = STATUS_CB_INIT ;
696
- struct pathspec pathspec ;
704
+ struct pathspec pathspec = { 0 } ;
697
705
struct module_list list = MODULE_LIST_INIT ;
698
706
int quiet = 0 ;
699
707
struct option module_status_options [] = {
@@ -706,20 +714,24 @@ static int module_status(int argc, const char **argv, const char *prefix)
706
714
N_ ("git submodule status [--quiet] [--cached] [--recursive] [<path>...]" ),
707
715
NULL
708
716
};
717
+ int ret = 1 ;
709
718
710
719
argc = parse_options (argc , argv , prefix , module_status_options ,
711
720
git_submodule_helper_usage , 0 );
712
721
713
722
if (module_list_compute (argc , argv , prefix , & pathspec , & list ) < 0 )
714
- return 1 ;
723
+ goto cleanup ;
715
724
716
725
info .prefix = prefix ;
717
726
if (quiet )
718
727
info .flags |= OPT_QUIET ;
719
728
720
729
for_each_listed_submodule (& list , status_submodule_cb , & info );
721
730
722
- return 0 ;
731
+ ret = 0 ;
732
+ cleanup :
733
+ clear_pathspec (& pathspec );
734
+ return ret ;
723
735
}
724
736
725
737
struct module_cb {
@@ -1258,7 +1270,7 @@ static void sync_submodule_cb(const struct cache_entry *list_item, void *cb_data
1258
1270
static int module_sync (int argc , const char * * argv , const char * prefix )
1259
1271
{
1260
1272
struct sync_cb info = SYNC_CB_INIT ;
1261
- struct pathspec pathspec ;
1273
+ struct pathspec pathspec = { 0 } ;
1262
1274
struct module_list list = MODULE_LIST_INIT ;
1263
1275
int quiet = 0 ;
1264
1276
int recursive = 0 ;
@@ -1272,12 +1284,13 @@ static int module_sync(int argc, const char **argv, const char *prefix)
1272
1284
N_ ("git submodule sync [--quiet] [--recursive] [<path>]" ),
1273
1285
NULL
1274
1286
};
1287
+ int ret = 1 ;
1275
1288
1276
1289
argc = parse_options (argc , argv , prefix , module_sync_options ,
1277
1290
git_submodule_helper_usage , 0 );
1278
1291
1279
1292
if (module_list_compute (argc , argv , prefix , & pathspec , & list ) < 0 )
1280
- return 1 ;
1293
+ goto cleanup ;
1281
1294
1282
1295
info .prefix = prefix ;
1283
1296
if (quiet )
@@ -1287,7 +1300,10 @@ static int module_sync(int argc, const char **argv, const char *prefix)
1287
1300
1288
1301
for_each_listed_submodule (& list , sync_submodule_cb , & info );
1289
1302
1290
- return 0 ;
1303
+ ret = 0 ;
1304
+ cleanup :
1305
+ clear_pathspec (& pathspec );
1306
+ return ret ;
1291
1307
}
1292
1308
1293
1309
struct deinit_cb {
@@ -1396,7 +1412,7 @@ static void deinit_submodule_cb(const struct cache_entry *list_item,
1396
1412
static int module_deinit (int argc , const char * * argv , const char * prefix )
1397
1413
{
1398
1414
struct deinit_cb info = DEINIT_CB_INIT ;
1399
- struct pathspec pathspec ;
1415
+ struct pathspec pathspec = { 0 } ;
1400
1416
struct module_list list = MODULE_LIST_INIT ;
1401
1417
int quiet = 0 ;
1402
1418
int force = 0 ;
@@ -1411,6 +1427,7 @@ static int module_deinit(int argc, const char **argv, const char *prefix)
1411
1427
N_ ("git submodule deinit [--quiet] [-f | --force] [--all | [--] [<path>...]]" ),
1412
1428
NULL
1413
1429
};
1430
+ int ret = 1 ;
1414
1431
1415
1432
argc = parse_options (argc , argv , prefix , module_deinit_options ,
1416
1433
git_submodule_helper_usage , 0 );
@@ -1425,7 +1442,7 @@ static int module_deinit(int argc, const char **argv, const char *prefix)
1425
1442
die (_ ("Use '--all' if you really want to deinitialize all submodules" ));
1426
1443
1427
1444
if (module_list_compute (argc , argv , prefix , & pathspec , & list ) < 0 )
1428
- return 1 ;
1445
+ goto cleanup ;
1429
1446
1430
1447
info .prefix = prefix ;
1431
1448
if (quiet )
@@ -1435,7 +1452,10 @@ static int module_deinit(int argc, const char **argv, const char *prefix)
1435
1452
1436
1453
for_each_listed_submodule (& list , deinit_submodule_cb , & info );
1437
1454
1438
- return 0 ;
1455
+ ret = 0 ;
1456
+ cleanup :
1457
+ clear_pathspec (& pathspec );
1458
+ return ret ;
1439
1459
}
1440
1460
1441
1461
struct module_clone_data {
@@ -2540,7 +2560,7 @@ static int update_submodules(struct update_data *update_data)
2540
2560
2541
2561
static int module_update (int argc , const char * * argv , const char * prefix )
2542
2562
{
2543
- struct pathspec pathspec ;
2563
+ struct pathspec pathspec = { 0 } ;
2544
2564
struct update_data opt = UPDATE_DATA_INIT ;
2545
2565
struct list_objects_filter_options filter_options = { 0 };
2546
2566
int ret ;
@@ -2617,8 +2637,8 @@ static int module_update(int argc, const char **argv, const char *prefix)
2617
2637
opt .update_strategy .type = opt .update_default ;
2618
2638
2619
2639
if (module_list_compute (argc , argv , prefix , & pathspec , & opt .list ) < 0 ) {
2620
- list_objects_filter_release ( & filter_options ) ;
2621
- return 1 ;
2640
+ ret = 1 ;
2641
+ goto cleanup ;
2622
2642
}
2623
2643
2624
2644
if (pathspec .nr )
@@ -2629,8 +2649,10 @@ static int module_update(int argc, const char **argv, const char *prefix)
2629
2649
struct init_cb info = INIT_CB_INIT ;
2630
2650
2631
2651
if (module_list_compute (argc , argv , opt .prefix ,
2632
- & pathspec , & list ) < 0 )
2633
- return 1 ;
2652
+ & pathspec , & list ) < 0 ) {
2653
+ ret = 1 ;
2654
+ goto cleanup ;
2655
+ }
2634
2656
2635
2657
/*
2636
2658
* If there are no path args and submodule.active is set then,
@@ -2647,7 +2669,9 @@ static int module_update(int argc, const char **argv, const char *prefix)
2647
2669
}
2648
2670
2649
2671
ret = update_submodules (& opt );
2672
+ cleanup :
2650
2673
list_objects_filter_release (& filter_options );
2674
+ clear_pathspec (& pathspec );
2651
2675
return ret ;
2652
2676
}
2653
2677
@@ -2731,7 +2755,7 @@ static int push_check(int argc, const char **argv, const char *prefix)
2731
2755
static int absorb_git_dirs (int argc , const char * * argv , const char * prefix )
2732
2756
{
2733
2757
int i ;
2734
- struct pathspec pathspec ;
2758
+ struct pathspec pathspec = { 0 } ;
2735
2759
struct module_list list = MODULE_LIST_INIT ;
2736
2760
unsigned flags = ABSORB_GITDIR_RECURSE_SUBMODULES ;
2737
2761
struct option embed_gitdir_options [] = {
@@ -2746,17 +2770,21 @@ static int absorb_git_dirs(int argc, const char **argv, const char *prefix)
2746
2770
N_ ("git submodule absorbgitdirs [<options>] [<path>...]" ),
2747
2771
NULL
2748
2772
};
2773
+ int ret = 1 ;
2749
2774
2750
2775
argc = parse_options (argc , argv , prefix , embed_gitdir_options ,
2751
2776
git_submodule_helper_usage , 0 );
2752
2777
2753
2778
if (module_list_compute (argc , argv , prefix , & pathspec , & list ) < 0 )
2754
- return 1 ;
2779
+ goto cleanup ;
2755
2780
2756
2781
for (i = 0 ; i < list .nr ; i ++ )
2757
2782
absorb_git_dir_into_superproject (list .entries [i ]-> name , flags );
2758
2783
2759
- return 0 ;
2784
+ ret = 0 ;
2785
+ cleanup :
2786
+ clear_pathspec (& pathspec );
2787
+ return ret ;
2760
2788
}
2761
2789
2762
2790
static int module_config (int argc , const char * * argv , const char * prefix )
0 commit comments