@@ -1730,24 +1730,27 @@ static int module_clone(int argc, const char **argv, const char *prefix)
1730
1730
return 0 ;
1731
1731
}
1732
1732
1733
- static void determine_submodule_update_strategy (struct repository * r ,
1734
- int just_cloned ,
1735
- const char * path ,
1736
- enum submodule_update_type update ,
1737
- struct submodule_update_strategy * out )
1733
+ static int determine_submodule_update_strategy (struct repository * r ,
1734
+ int just_cloned ,
1735
+ const char * path ,
1736
+ enum submodule_update_type update ,
1737
+ struct submodule_update_strategy * out )
1738
1738
{
1739
1739
const struct submodule * sub = submodule_from_path (r , null_oid (), path );
1740
1740
char * key ;
1741
1741
const char * val ;
1742
+ int ret ;
1742
1743
1743
1744
key = xstrfmt ("submodule.%s.update" , sub -> name );
1744
1745
1745
1746
if (update ) {
1746
1747
out -> type = update ;
1747
1748
} else if (!repo_config_get_string_tmp (r , key , & val )) {
1748
- if (parse_submodule_update_strategy (val , out ) < 0 )
1749
- die (_ ("Invalid update mode '%s' configured for submodule path '%s'" ),
1750
- val , path );
1749
+ if (parse_submodule_update_strategy (val , out ) < 0 ) {
1750
+ ret = die_message (_ ("Invalid update mode '%s' configured for submodule path '%s'" ),
1751
+ val , path );
1752
+ goto cleanup ;
1753
+ }
1751
1754
} else if (sub -> update_strategy .type != SM_UPDATE_UNSPECIFIED ) {
1752
1755
if (sub -> update_strategy .type == SM_UPDATE_COMMAND )
1753
1756
BUG ("how did we read update = !command from .gitmodules?" );
@@ -1762,7 +1765,10 @@ static void determine_submodule_update_strategy(struct repository *r,
1762
1765
out -> type == SM_UPDATE_NONE ))
1763
1766
out -> type = SM_UPDATE_CHECKOUT ;
1764
1767
1768
+ ret = 0 ;
1769
+ cleanup :
1765
1770
free (key );
1771
+ return ret ;
1766
1772
}
1767
1773
1768
1774
struct update_clone_data {
@@ -2388,14 +2394,22 @@ static void update_data_to_args(const struct update_data *update_data,
2388
2394
static int update_submodule (struct update_data * update_data ,
2389
2395
int * must_die_on_failure )
2390
2396
{
2397
+ int ret ;
2398
+
2391
2399
ensure_core_worktree (update_data -> sm_path );
2392
2400
2393
2401
update_data -> displaypath = get_submodule_displaypath (
2394
2402
update_data -> sm_path , update_data -> prefix );
2395
2403
2396
- determine_submodule_update_strategy (the_repository , update_data -> just_cloned ,
2397
- update_data -> sm_path , update_data -> update_default ,
2398
- & update_data -> update_strategy );
2404
+ ret = determine_submodule_update_strategy (the_repository ,
2405
+ update_data -> just_cloned ,
2406
+ update_data -> sm_path ,
2407
+ update_data -> update_default ,
2408
+ & update_data -> update_strategy );
2409
+ if (ret ) {
2410
+ * must_die_on_failure = 1 ;
2411
+ return ret ;
2412
+ }
2399
2413
2400
2414
if (update_data -> just_cloned )
2401
2415
oidcpy (& update_data -> suboid , null_oid ());
@@ -2423,8 +2437,6 @@ static int update_submodule(struct update_data *update_data,
2423
2437
}
2424
2438
2425
2439
if (!oideq (& update_data -> oid , & update_data -> suboid ) || update_data -> force ) {
2426
- int ret ;
2427
-
2428
2440
ret = run_update_procedure (update_data , must_die_on_failure );
2429
2441
if (* must_die_on_failure )
2430
2442
return ret ;
@@ -2435,7 +2447,6 @@ static int update_submodule(struct update_data *update_data,
2435
2447
if (update_data -> recursive ) {
2436
2448
struct child_process cp = CHILD_PROCESS_INIT ;
2437
2449
struct update_data next = * update_data ;
2438
- int ret ;
2439
2450
2440
2451
next .prefix = NULL ;
2441
2452
oidcpy (& next .oid , null_oid ());
0 commit comments