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

Function submodule_to_gitdir

submodule.c:2702–2734  ·  view source on GitHub ↗

* Put the gitdir for a submodule (given relative to the main * repository worktree) into `buf`, or return -1 on error. */

Source from the content-addressed store, hash-verified

2700 * repository worktree) into `buf`, or return -1 on error.
2701 */
2702int submodule_to_gitdir(struct repository *repo,
2703 struct strbuf *buf, const char *submodule)
2704{
2705 const struct submodule *sub;
2706 const char *git_dir;
2707 int ret = 0;
2708
2709 if (validate_submodule_path(submodule) < 0)
2710 exit(128);
2711
2712 strbuf_reset(buf);
2713 strbuf_addstr(buf, submodule);
2714 strbuf_complete(buf, '/');
2715 strbuf_addstr(buf, ".git");
2716
2717 git_dir = read_gitfile(buf->buf);
2718 if (git_dir) {
2719 strbuf_reset(buf);
2720 strbuf_addstr(buf, git_dir);
2721 }
2722 if (!is_git_directory(buf->buf)) {
2723 sub = submodule_from_path(repo, null_oid(the_hash_algo), submodule);
2724 if (!sub) {
2725 ret = -1;
2726 goto cleanup;
2727 }
2728 strbuf_reset(buf);
2729 submodule_name_to_gitdir(buf, repo, sub->name);
2730 }
2731
2732cleanup:
2733 return ret;
2734}
2735
2736void submodule_name_to_gitdir(struct strbuf *buf, struct repository *r,
2737 const char *submodule_name)

Callers 4

do_submodule_pathFunction · 0.85
open_submoduleFunction · 0.85
sync_submoduleFunction · 0.85

Calls 7

validate_submodule_pathFunction · 0.85
strbuf_addstrFunction · 0.85
strbuf_completeFunction · 0.85
is_git_directoryFunction · 0.85
submodule_from_pathFunction · 0.85
null_oidFunction · 0.85
submodule_name_to_gitdirFunction · 0.85

Tested by

no test coverage detected