| 2400 | } |
| 2401 | |
| 2402 | static int validate_submodule_legacy_git_dir(char *git_dir, const char *submodule_name) |
| 2403 | { |
| 2404 | size_t len = strlen(git_dir), suffix_len = strlen(submodule_name); |
| 2405 | char *p; |
| 2406 | int ret = 0; |
| 2407 | |
| 2408 | if (the_repository->repository_format_submodule_path_cfg) |
| 2409 | BUG("validate_submodule_git_dir() must be called with " |
| 2410 | "extensions.submodulePathConfig disabled."); |
| 2411 | |
| 2412 | if (len <= suffix_len || (p = git_dir + len - suffix_len)[-1] != '/' || |
| 2413 | strcmp(p, submodule_name)) |
| 2414 | BUG("submodule name '%s' not a suffix of git dir '%s'", |
| 2415 | submodule_name, git_dir); |
| 2416 | |
| 2417 | /* |
| 2418 | * We prevent the contents of sibling submodules' git directories to |
| 2419 | * clash. |
| 2420 | * |
| 2421 | * Example: having a submodule named `hippo` and another one named |
| 2422 | * `hippo/hooks` would result in the git directories |
| 2423 | * `.git/modules/hippo/` and `.git/modules/hippo/hooks/`, respectively, |
| 2424 | * but the latter directory is already designated to contain the hooks |
| 2425 | * of the former. |
| 2426 | */ |
| 2427 | for (; *p; p++) { |
| 2428 | if (is_dir_sep(*p)) { |
| 2429 | char c = *p; |
| 2430 | |
| 2431 | *p = '\0'; |
| 2432 | if (is_git_directory(git_dir)) |
| 2433 | ret = -1; |
| 2434 | *p = c; |
| 2435 | |
| 2436 | if (ret < 0) |
| 2437 | return error(_("submodule git dir '%s' is " |
| 2438 | "inside git dir '%.*s'"), |
| 2439 | git_dir, |
| 2440 | (int)(p - git_dir), git_dir); |
| 2441 | } |
| 2442 | } |
| 2443 | |
| 2444 | return 0; |
| 2445 | } |
| 2446 | |
| 2447 | int validate_submodule_git_dir(char *git_dir, const char *submodule_name) |
| 2448 | { |
no test coverage detected