submodule--helper: return error from set-url when modifying failed

set-branch will return an error when setting the config fails so I don't
see why set-url shouldn't. Also skip the sync in this case.

Signed-off-by: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Jan Alexander Steffens (heftig)
2023-10-03 20:50:43 +02:00
committed by Junio C Hamano
parent 6327085aa0
commit 387c122131

View File

@ -2889,7 +2889,7 @@ cleanup:
static int module_set_url(int argc, const char **argv, const char *prefix) static int module_set_url(int argc, const char **argv, const char *prefix)
{ {
int quiet = 0; int quiet = 0, ret;
const char *newurl; const char *newurl;
const char *path; const char *path;
char *config_name; char *config_name;
@ -2915,13 +2915,15 @@ static int module_set_url(int argc, const char **argv, const char *prefix)
path); path);
config_name = xstrfmt("submodule.%s.url", sub->name); config_name = xstrfmt("submodule.%s.url", sub->name);
config_set_in_gitmodules_file_gently(config_name, newurl); ret = config_set_in_gitmodules_file_gently(config_name, newurl);
repo_read_gitmodules (the_repository, 0); if (!ret) {
sync_submodule(sub->path, prefix, NULL, quiet ? OPT_QUIET : 0); repo_read_gitmodules(the_repository, 0);
sync_submodule(sub->path, prefix, NULL, quiet ? OPT_QUIET : 0);
}
free(config_name); free(config_name);
return 0; return !!ret;
} }
static int module_set_branch(int argc, const char **argv, const char *prefix) static int module_set_branch(int argc, const char **argv, const char *prefix)