@@ -437,20 +437,21 @@ static int starts_with_dot_dot_slash(const char *const path)
437
437
438
438
struct init_cb {
439
439
const char * prefix ;
440
+ const char * super_prefix ;
440
441
unsigned int flags ;
441
442
};
442
443
#define INIT_CB_INIT { 0 }
443
444
444
445
static void init_submodule (const char * path , const char * prefix ,
446
+ const char * super_prefix ,
445
447
unsigned int flags )
446
448
{
447
449
const struct submodule * sub ;
448
450
struct strbuf sb = STRBUF_INIT ;
449
451
const char * upd ;
450
452
char * url = NULL , * displaypath ;
451
453
452
- displaypath = get_submodule_displaypath (path , prefix ,
453
- get_super_prefix ());
454
+ displaypath = get_submodule_displaypath (path , prefix , super_prefix );
454
455
455
456
sub = submodule_from_path (the_repository , null_oid (), path );
456
457
@@ -526,7 +527,8 @@ static void init_submodule_cb(const struct cache_entry *list_item, void *cb_data
526
527
{
527
528
struct init_cb * info = cb_data ;
528
529
529
- init_submodule (list_item -> name , info -> prefix , info -> flags );
530
+ init_submodule (list_item -> name , info -> prefix , info -> super_prefix ,
531
+ info -> flags );
530
532
}
531
533
532
534
static int module_init (int argc , const char * * argv , const char * prefix )
@@ -792,6 +794,7 @@ struct summary_cb {
792
794
int argc ;
793
795
const char * * argv ;
794
796
const char * prefix ;
797
+ const char * super_prefix ;
795
798
unsigned int cached : 1 ;
796
799
unsigned int for_status : 1 ;
797
800
unsigned int files : 1 ;
@@ -954,7 +957,7 @@ static void generate_submodule_summary(struct summary_cb *info,
954
957
}
955
958
956
959
displaypath = get_submodule_displaypath (p -> sm_path , info -> prefix ,
957
- get_super_prefix () );
960
+ info -> super_prefix );
958
961
959
962
if (!missing_src && !missing_dst ) {
960
963
struct child_process cp_rev_list = CHILD_PROCESS_INIT ;
@@ -1893,6 +1896,7 @@ static void submodule_update_clone_release(struct submodule_update_clone *suc)
1893
1896
1894
1897
struct update_data {
1895
1898
const char * prefix ;
1899
+ const char * super_prefix ;
1896
1900
char * displaypath ;
1897
1901
enum submodule_update_type update_default ;
1898
1902
struct object_id suboid ;
@@ -1969,7 +1973,7 @@ static int prepare_to_clone_next_submodule(const struct cache_entry *ce,
1969
1973
char * key ;
1970
1974
const struct update_data * ud = suc -> update_data ;
1971
1975
char * displaypath = get_submodule_displaypath (ce -> name , ud -> prefix ,
1972
- get_super_prefix () );
1976
+ ud -> super_prefix );
1973
1977
struct strbuf sb = STRBUF_INIT ;
1974
1978
int needs_cloning = 0 ;
1975
1979
int need_free_url = 0 ;
@@ -2449,11 +2453,11 @@ static void update_data_to_args(const struct update_data *update_data,
2449
2453
{
2450
2454
enum submodule_update_type update_type = update_data -> update_default ;
2451
2455
2456
+ strvec_pushl (args , "submodule--helper" , "update" , "--recursive" , NULL );
2452
2457
if (update_data -> displaypath ) {
2453
2458
strvec_push (args , "--super-prefix" );
2454
2459
strvec_pushf (args , "%s/" , update_data -> displaypath );
2455
2460
}
2456
- strvec_pushl (args , "submodule--helper" , "update" , "--recursive" , NULL );
2457
2461
strvec_pushf (args , "--jobs=%d" , update_data -> max_jobs );
2458
2462
if (update_data -> quiet )
2459
2463
strvec_push (args , "--quiet" );
@@ -2620,7 +2624,7 @@ static int update_submodules(struct update_data *update_data)
2620
2624
2621
2625
update_data -> displaypath = get_submodule_displaypath (
2622
2626
update_data -> sm_path , update_data -> prefix ,
2623
- get_super_prefix () );
2627
+ update_data -> super_prefix );
2624
2628
code = update_submodule (update_data );
2625
2629
FREE_AND_NULL (update_data -> displaypath );
2626
2630
fail :
@@ -2646,6 +2650,7 @@ static int module_update(int argc, const char **argv, const char *prefix)
2646
2650
LIST_OBJECTS_FILTER_INIT ;
2647
2651
int ret ;
2648
2652
struct option module_update_options [] = {
2653
+ OPT__SUPER_PREFIX (& opt .super_prefix ),
2649
2654
OPT__FORCE (& opt .force , N_ ("force checkout updates" ), 0 ),
2650
2655
OPT_BOOL (0 , "init" , & opt .init ,
2651
2656
N_ ("initialize uninitialized submodules before update" )),
@@ -2742,6 +2747,7 @@ static int module_update(int argc, const char **argv, const char *prefix)
2742
2747
module_list_active (& list );
2743
2748
2744
2749
info .prefix = opt .prefix ;
2750
+ info .super_prefix = opt .super_prefix ;
2745
2751
if (opt .quiet )
2746
2752
info .flags |= OPT_QUIET ;
2747
2753
@@ -3368,8 +3374,6 @@ static int module_add(int argc, const char **argv, const char *prefix)
3368
3374
3369
3375
int cmd_submodule__helper (int argc , const char * * argv , const char * prefix )
3370
3376
{
3371
- const char * cmd = argv [0 ];
3372
- const char * subcmd ;
3373
3377
parse_opt_subcommand_fn * fn = NULL ;
3374
3378
const char * const usage [] = {
3375
3379
N_ ("git submodule--helper <command>" ),
@@ -3393,16 +3397,6 @@ int cmd_submodule__helper(int argc, const char **argv, const char *prefix)
3393
3397
OPT_END ()
3394
3398
};
3395
3399
argc = parse_options (argc , argv , prefix , options , usage , 0 );
3396
- subcmd = argv [0 ];
3397
-
3398
- if (strcmp (subcmd , "clone" ) && strcmp (subcmd , "update" ) &&
3399
- get_super_prefix ())
3400
- /*
3401
- * xstrfmt() rather than "%s %s" to keep the translated
3402
- * string identical to git.c's.
3403
- */
3404
- die (_ ("%s doesn't support --super-prefix" ),
3405
- xstrfmt ("'%s %s'" , cmd , subcmd ));
3406
3400
3407
3401
return fn (argc , argv , prefix );
3408
3402
}
0 commit comments