| 475 | #define INIT_CB_INIT { 0 } |
| 476 | |
| 477 | static int validate_and_set_submodule_gitdir(struct strbuf *gitdir_path, |
| 478 | const char *submodule_name) |
| 479 | { |
| 480 | const char *value; |
| 481 | char *key; |
| 482 | |
| 483 | if (validate_submodule_git_dir(gitdir_path->buf, submodule_name)) |
| 484 | return -1; |
| 485 | |
| 486 | key = xstrfmt("submodule.%s.gitdir", submodule_name); |
| 487 | |
| 488 | /* Nothing to do if the config already exists. */ |
| 489 | if (!repo_config_get_string_tmp(the_repository, key, &value)) { |
| 490 | free(key); |
| 491 | return 0; |
| 492 | } |
| 493 | |
| 494 | if (repo_config_set_gently(the_repository, key, gitdir_path->buf)) { |
| 495 | free(key); |
| 496 | return -1; |
| 497 | } |
| 498 | |
| 499 | free(key); |
| 500 | return 0; |
| 501 | } |
| 502 | |
| 503 | static void create_default_gitdir_config(const char *submodule_name) |
| 504 | { |
no test coverage detected