MCPcopy Create free account
hub / github.com/git/git / get_default_remote_submodule

Function get_default_remote_submodule

builtin/submodule--helper.c:77–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75}
76
77static int get_default_remote_submodule(const char *module_path, char **default_remote)
78{
79 const struct submodule *sub;
80 struct repository subrepo;
81 const char *remote_name = NULL;
82 char *url = NULL;
83
84 sub = submodule_from_path(the_repository, null_oid(the_hash_algo), module_path);
85 if (sub && sub->url) {
86 url = xstrdup(sub->url);
87
88 /* Possibly a url relative to parent */
89 if (starts_with_dot_dot_slash(url) ||
90 starts_with_dot_slash(url)) {
91 char *oldurl = url;
92
93 url = resolve_relative_url(oldurl, NULL, 1);
94 free(oldurl);
95 }
96 }
97
98 if (repo_submodule_init(&subrepo, the_repository, module_path,
99 null_oid(the_hash_algo)) < 0)
100 return die_message(_("could not get a repository handle for submodule '%s'"),
101 module_path);
102
103 /* Look up by URL first */
104 if (url)
105 remote_name = repo_remote_from_url(&subrepo, url);
106 if (!remote_name)
107 remote_name = repo_default_remote(&subrepo);
108
109 *default_remote = xstrdup(remote_name);
110
111 repo_clear(&subrepo);
112 free(url);
113
114 return 0;
115}
116
117static int module_get_default_remote(int argc, const char **argv, const char *prefix,
118 struct repository *repo UNUSED)

Callers 4

sync_submoduleFunction · 0.85
fetch_in_submoduleFunction · 0.85
update_submoduleFunction · 0.85

Calls 11

submodule_from_pathFunction · 0.85
null_oidFunction · 0.85
xstrdupFunction · 0.85
starts_with_dot_slashFunction · 0.85
resolve_relative_urlFunction · 0.85
repo_submodule_initFunction · 0.85
die_messageFunction · 0.85
repo_remote_from_urlFunction · 0.85
repo_default_remoteFunction · 0.85
repo_clearFunction · 0.85

Tested by

no test coverage detected