@@ -118,10 +118,11 @@ static int resolve_relative_url_test(int argc, const char **argv, const char *pr
118
118
return 0 ;
119
119
}
120
120
121
- static char * do_get_submodule_displaypath (const char * path ,
122
- const char * prefix ,
123
- const char * super_prefix )
121
+ /* the result should be freed by the caller. */
122
+ static char * get_submodule_displaypath (const char * path , const char * prefix )
124
123
{
124
+ const char * super_prefix = get_super_prefix ();
125
+
125
126
if (prefix && super_prefix ) {
126
127
BUG ("cannot have prefix '%s' and superprefix '%s'" ,
127
128
prefix , super_prefix );
@@ -137,13 +138,6 @@ static char *do_get_submodule_displaypath(const char *path,
137
138
}
138
139
}
139
140
140
- /* the result should be freed by the caller. */
141
- static char * get_submodule_displaypath (const char * path , const char * prefix )
142
- {
143
- const char * super_prefix = get_super_prefix ();
144
- return do_get_submodule_displaypath (path , prefix , super_prefix );
145
- }
146
-
147
141
static char * compute_rev_name (const char * sub_path , const char * object_id )
148
142
{
149
143
struct strbuf sb = STRBUF_INIT ;
@@ -477,22 +471,18 @@ static int starts_with_dot_dot_slash(const char *const path)
477
471
478
472
struct init_cb {
479
473
const char * prefix ;
480
- const char * superprefix ;
481
474
unsigned int flags ;
482
475
};
483
476
#define INIT_CB_INIT { 0 }
484
477
485
478
static void init_submodule (const char * path , const char * prefix ,
486
- const char * superprefix , unsigned int flags )
479
+ unsigned int flags )
487
480
{
488
481
const struct submodule * sub ;
489
482
struct strbuf sb = STRBUF_INIT ;
490
483
char * upd = NULL , * url = NULL , * displaypath ;
491
484
492
- /* try superprefix from the environment, if it is not passed explicitly */
493
- if (!superprefix )
494
- superprefix = get_super_prefix ();
495
- displaypath = do_get_submodule_displaypath (path , prefix , superprefix );
485
+ displaypath = get_submodule_displaypath (path , prefix );
496
486
497
487
sub = submodule_from_path (the_repository , null_oid (), path );
498
488
@@ -566,7 +556,7 @@ static void init_submodule(const char *path, const char *prefix,
566
556
static void init_submodule_cb (const struct cache_entry * list_item , void * cb_data )
567
557
{
568
558
struct init_cb * info = cb_data ;
569
- init_submodule (list_item -> name , info -> prefix , info -> superprefix , info -> flags );
559
+ init_submodule (list_item -> name , info -> prefix , info -> flags );
570
560
}
571
561
572
562
static int module_init (int argc , const char * * argv , const char * prefix )
@@ -1878,7 +1868,6 @@ struct submodule_update_clone {
1878
1868
1879
1869
struct update_data {
1880
1870
const char * prefix ;
1881
- const char * recursive_prefix ;
1882
1871
const char * displaypath ;
1883
1872
enum submodule_update_type update_default ;
1884
1873
struct object_id suboid ;
@@ -1947,30 +1936,20 @@ static int prepare_to_clone_next_submodule(const struct cache_entry *ce,
1947
1936
const char * update_string ;
1948
1937
enum submodule_update_type update_type ;
1949
1938
char * key ;
1950
- struct strbuf displaypath_sb = STRBUF_INIT ;
1939
+ struct update_data * ud = suc -> update_data ;
1940
+ char * displaypath = get_submodule_displaypath (ce -> name , ud -> prefix );
1951
1941
struct strbuf sb = STRBUF_INIT ;
1952
- const char * displaypath = NULL ;
1953
1942
int needs_cloning = 0 ;
1954
1943
int need_free_url = 0 ;
1955
1944
1956
1945
if (ce_stage (ce )) {
1957
- if (suc -> update_data -> recursive_prefix )
1958
- strbuf_addf (& sb , "%s/%s" , suc -> update_data -> recursive_prefix , ce -> name );
1959
- else
1960
- strbuf_addstr (& sb , ce -> name );
1961
- strbuf_addf (out , _ ("Skipping unmerged submodule %s" ), sb .buf );
1946
+ strbuf_addf (out , _ ("Skipping unmerged submodule %s" ), displaypath );
1962
1947
strbuf_addch (out , '\n' );
1963
1948
goto cleanup ;
1964
1949
}
1965
1950
1966
1951
sub = submodule_from_path (the_repository , null_oid (), ce -> name );
1967
1952
1968
- if (suc -> update_data -> recursive_prefix )
1969
- displaypath = relative_path (suc -> update_data -> recursive_prefix ,
1970
- ce -> name , & displaypath_sb );
1971
- else
1972
- displaypath = ce -> name ;
1973
-
1974
1953
if (!sub ) {
1975
1954
next_submodule_warn_missing (suc , out , displaypath );
1976
1955
goto cleanup ;
@@ -2060,7 +2039,7 @@ static int prepare_to_clone_next_submodule(const struct cache_entry *ce,
2060
2039
"--no-single-branch" );
2061
2040
2062
2041
cleanup :
2063
- strbuf_release ( & displaypath_sb );
2042
+ free ( displaypath );
2064
2043
strbuf_release (& sb );
2065
2044
if (need_free_url )
2066
2045
free ((void * )url );
@@ -2424,11 +2403,12 @@ static void update_data_to_args(struct update_data *update_data, struct strvec *
2424
2403
{
2425
2404
enum submodule_update_type update_type = update_data -> update_default ;
2426
2405
2406
+ if (update_data -> displaypath ) {
2407
+ strvec_push (args , "--super-prefix" );
2408
+ strvec_pushf (args , "%s/" , update_data -> displaypath );
2409
+ }
2427
2410
strvec_pushl (args , "submodule--helper" , "update" , "--recursive" , NULL );
2428
2411
strvec_pushf (args , "--jobs=%d" , update_data -> max_jobs );
2429
- if (update_data -> recursive_prefix )
2430
- strvec_pushl (args , "--recursive-prefix" ,
2431
- update_data -> recursive_prefix , NULL );
2432
2412
if (update_data -> quiet )
2433
2413
strvec_push (args , "--quiet" );
2434
2414
if (update_data -> force )
@@ -2472,19 +2452,10 @@ static void update_data_to_args(struct update_data *update_data, struct strvec *
2472
2452
2473
2453
static int update_submodule (struct update_data * update_data )
2474
2454
{
2475
- char * prefixed_path ;
2476
-
2477
2455
ensure_core_worktree (update_data -> sm_path );
2478
2456
2479
- if (update_data -> recursive_prefix )
2480
- prefixed_path = xstrfmt ("%s%s" , update_data -> recursive_prefix ,
2481
- update_data -> sm_path );
2482
- else
2483
- prefixed_path = xstrdup (update_data -> sm_path );
2484
-
2485
- update_data -> displaypath = get_submodule_displaypath (prefixed_path ,
2486
- update_data -> prefix );
2487
- free (prefixed_path );
2457
+ update_data -> displaypath = get_submodule_displaypath (
2458
+ update_data -> sm_path , update_data -> prefix );
2488
2459
2489
2460
determine_submodule_update_strategy (the_repository , update_data -> just_cloned ,
2490
2461
update_data -> sm_path , update_data -> update_default ,
@@ -2524,14 +2495,6 @@ static int update_submodule(struct update_data *update_data)
2524
2495
struct update_data next = * update_data ;
2525
2496
int res ;
2526
2497
2527
- if (update_data -> recursive_prefix )
2528
- prefixed_path = xstrfmt ("%s%s/" , update_data -> recursive_prefix ,
2529
- update_data -> sm_path );
2530
- else
2531
- prefixed_path = xstrfmt ("%s/" , update_data -> sm_path );
2532
-
2533
- next .recursive_prefix = get_submodule_displaypath (prefixed_path ,
2534
- update_data -> prefix );
2535
2498
next .prefix = NULL ;
2536
2499
oidcpy (& next .oid , null_oid ());
2537
2500
oidcpy (& next .suboid , null_oid ());
@@ -2616,10 +2579,6 @@ static int module_update(int argc, const char **argv, const char *prefix)
2616
2579
OPT_STRING (0 , "prefix" , & opt .prefix ,
2617
2580
N_ ("path" ),
2618
2581
N_ ("path into the working tree" )),
2619
- OPT_STRING (0 , "recursive-prefix" , & opt .recursive_prefix ,
2620
- N_ ("path" ),
2621
- N_ ("path into the working tree, across nested "
2622
- "submodule boundaries" )),
2623
2582
OPT_SET_INT (0 , "checkout" , & opt .update_default ,
2624
2583
N_ ("use the 'checkout' update strategy (default)" ),
2625
2584
SM_UPDATE_CHECKOUT ),
@@ -2705,7 +2664,6 @@ static int module_update(int argc, const char **argv, const char *prefix)
2705
2664
module_list_active (& list );
2706
2665
2707
2666
info .prefix = opt .prefix ;
2708
- info .superprefix = opt .recursive_prefix ;
2709
2667
if (opt .quiet )
2710
2668
info .flags |= OPT_QUIET ;
2711
2669
@@ -3402,16 +3360,16 @@ struct cmd_struct {
3402
3360
static struct cmd_struct commands [] = {
3403
3361
{"list" , module_list , 0 },
3404
3362
{"name" , module_name , 0 },
3405
- {"clone" , module_clone , 0 },
3406
- {"add" , module_add , SUPPORT_SUPER_PREFIX },
3407
- {"update" , module_update , 0 },
3363
+ {"clone" , module_clone , SUPPORT_SUPER_PREFIX },
3364
+ {"add" , module_add , 0 },
3365
+ {"update" , module_update , SUPPORT_SUPER_PREFIX },
3408
3366
{"resolve-relative-url-test" , resolve_relative_url_test , 0 },
3409
3367
{"foreach" , module_foreach , SUPPORT_SUPER_PREFIX },
3410
- {"init" , module_init , SUPPORT_SUPER_PREFIX },
3368
+ {"init" , module_init , 0 },
3411
3369
{"status" , module_status , SUPPORT_SUPER_PREFIX },
3412
3370
{"sync" , module_sync , SUPPORT_SUPER_PREFIX },
3413
3371
{"deinit" , module_deinit , 0 },
3414
- {"summary" , module_summary , SUPPORT_SUPER_PREFIX },
3372
+ {"summary" , module_summary , 0 },
3415
3373
{"push-check" , push_check , 0 },
3416
3374
{"absorbgitdirs" , absorb_git_dirs , SUPPORT_SUPER_PREFIX },
3417
3375
{"is-active" , is_active , 0 },
0 commit comments