| 75 | } |
| 76 | |
| 77 | static 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 | |
| 117 | static int module_get_default_remote(int argc, const char **argv, const char *prefix, |
| 118 | struct repository *repo UNUSED) |
no test coverage detected