@@ -317,8 +317,12 @@ static void init_submodule(const char *path, const char *prefix, int quiet)
317317 /* Only loads from .gitmodules, no overlay with .git/config */
318318 gitmodules_config ();
319319
320- if (prefix ) {
321- strbuf_addf (& sb , "%s%s" , prefix , path );
320+ if (prefix && get_super_prefix ())
321+ die ("BUG: cannot have prefix and superprefix" );
322+ else if (prefix )
323+ displaypath = xstrdup (relative_path (path , prefix , & sb ));
324+ else if (get_super_prefix ()) {
325+ strbuf_addf (& sb , "%s%s" , get_super_prefix (), path );
322326 displaypath = strbuf_detach (& sb , NULL );
323327 } else
324328 displaypath = xstrdup (path );
@@ -403,9 +407,6 @@ static int module_init(int argc, const char **argv, const char *prefix)
403407 int i ;
404408
405409 struct option module_init_options [] = {
406- OPT_STRING (0 , "prefix" , & prefix ,
407- N_ ("path" ),
408- N_ ("alternative anchor for relative paths" )),
409410 OPT__QUIET (& quiet , N_ ("Suppress output for initializing a submodule" )),
410411 OPT_END ()
411412 };
@@ -1144,7 +1145,7 @@ static struct cmd_struct commands[] = {
11441145 {"relative-path" , resolve_relative_path , 0 },
11451146 {"resolve-relative-url" , resolve_relative_url , 0 },
11461147 {"resolve-relative-url-test" , resolve_relative_url_test , 0 },
1147- {"init" , module_init , 0 },
1148+ {"init" , module_init , SUPPORT_SUPER_PREFIX },
11481149 {"remote-branch" , resolve_remote_submodule_branch , 0 },
11491150 {"absorb-git-dirs" , absorb_git_dirs , SUPPORT_SUPER_PREFIX },
11501151};
0 commit comments