Skip to content

Commit

Permalink
submodule--helper: return error from set-url when modifying failed
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
heftig authored and gitster committed Oct 3, 2023
1 parent 6327085 commit 387c122
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions builtin/submodule--helper.c
Expand Up @@ -2889,7 +2889,7 @@ static int absorb_git_dirs(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 *path;
char *config_name;
Expand All @@ -2915,13 +2915,15 @@ static int module_set_url(int argc, const char **argv, const char *prefix)
path);

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);
sync_submodule(sub->path, prefix, NULL, quiet ? OPT_QUIET : 0);
if (!ret) {
repo_read_gitmodules(the_repository, 0);
sync_submodule(sub->path, prefix, NULL, quiet ? OPT_QUIET : 0);
}

free(config_name);
return 0;
return !!ret;
}

static int module_set_branch(int argc, const char **argv, const char *prefix)
Expand Down

0 comments on commit 387c122

Please sign in to comment.