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

Function module_set_url

builtin/submodule--helper.c:3228–3266  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3226}
3227
3228static int module_set_url(int argc, const char **argv, const char *prefix,
3229 struct repository *repo UNUSED)
3230{
3231 int quiet = 0, ret;
3232 const char *newurl;
3233 const char *path;
3234 char *config_name;
3235 struct option options[] = {
3236 OPT__QUIET(&quiet, N_("suppress output for setting url of a submodule")),
3237 OPT_END()
3238 };
3239 const char *const usage[] = {
3240 N_("git submodule set-url [--quiet] <path> <newurl>"),
3241 NULL
3242 };
3243 const struct submodule *sub;
3244
3245 argc = parse_options(argc, argv, prefix, options, usage, 0);
3246
3247 if (argc != 2 || !(path = argv[0]) || !(newurl = argv[1]))
3248 usage_with_options(usage, options);
3249
3250 sub = submodule_from_path(the_repository, null_oid(the_hash_algo), path);
3251
3252 if (!sub)
3253 die(_("no submodule mapping found in .gitmodules for path '%s'"),
3254 path);
3255
3256 config_name = xstrfmt("submodule.%s.url", sub->name);
3257 ret = config_set_in_gitmodules_file_gently(config_name, newurl);
3258
3259 if (!ret) {
3260 repo_read_gitmodules(the_repository, 0);
3261 sync_submodule(sub->path, prefix, NULL, quiet ? OPT_QUIET : 0);
3262 }
3263
3264 free(config_name);
3265 return !!ret;
3266}
3267
3268static int module_set_branch(int argc, const char **argv, const char *prefix,
3269 struct repository *repo UNUSED)

Callers

nothing calls this directly

Calls 9

parse_optionsFunction · 0.85
usage_with_optionsFunction · 0.85
submodule_from_pathFunction · 0.85
null_oidFunction · 0.85
xstrfmtFunction · 0.85
repo_read_gitmodulesFunction · 0.85
sync_submoduleFunction · 0.85
dieFunction · 0.50

Tested by

no test coverage detected