MCPcopy Index your code
hub / github.com/git/git / submodule_name_to_gitdir

Function submodule_name_to_gitdir

submodule.c:2736–2772  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2734}
2735
2736void submodule_name_to_gitdir(struct strbuf *buf, struct repository *r,
2737 const char *submodule_name)
2738{
2739 if (!r->repository_format_submodule_path_cfg) {
2740 /*
2741 * If extensions.submodulePathConfig is disabled,
2742 * continue to use the plain path.
2743 */
2744 repo_git_path_append(r, buf, "modules/%s", submodule_name);
2745 } else {
2746 const char *gitdir;
2747 char *key;
2748 int ret;
2749
2750 /* Otherwise the extension is enabled, so use the gitdir config. */
2751 key = xstrfmt("submodule.%s.gitdir", submodule_name);
2752 ret = repo_config_get_string_tmp(r, key, &gitdir);
2753 FREE_AND_NULL(key);
2754
2755 if (ret)
2756 die(_("the 'submodule.%s.gitdir' config does not exist for module '%s'. "
2757 "Please ensure it is set, for example by running something like: "
2758 "'git config submodule.%s.gitdir .git/modules/%s'. For details "
2759 "see the extensions.submodulePathConfig documentation."),
2760 submodule_name, submodule_name, submodule_name, submodule_name);
2761
2762 strbuf_addstr(buf, gitdir);
2763 }
2764
2765 /* validate because users might have modified the config */
2766 if (validate_submodule_git_dir(buf->buf, submodule_name)) {
2767 advise(_("enabling extensions.submodulePathConfig might fix the "
2768 "following error, if it's not already enabled."));
2769 die(_("refusing to create/use '%s' in another submodule's "
2770 " git dir."), buf->buf);
2771 }
2772}

Callers 11

submodule_move_headFunction · 0.85
submodule_to_gitdirFunction · 0.85
repo_submodule_initFunction · 0.85
module_gitdirFunction · 0.85
add_submoduleFunction · 0.85

Calls 7

repo_git_path_appendFunction · 0.85
xstrfmtFunction · 0.85
strbuf_addstrFunction · 0.85
adviseFunction · 0.85
dieFunction · 0.70

Tested by

no test coverage detected