| 3226 | } |
| 3227 | |
| 3228 | static 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 | |
| 3268 | static int module_set_branch(int argc, const char **argv, const char *prefix, |
| 3269 | struct repository *repo UNUSED) |
nothing calls this directly
no test coverage detected