Skip to content

Commit 387c122

Browse files
heftiggitster
authored andcommitted
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) <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 6327085 commit 387c122

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

builtin/submodule--helper.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2889,7 +2889,7 @@ static int absorb_git_dirs(int argc, const char **argv, const char *prefix)
28892889

28902890
static int module_set_url(int argc, const char **argv, const char *prefix)
28912891
{
2892-
int quiet = 0;
2892+
int quiet = 0, ret;
28932893
const char *newurl;
28942894
const char *path;
28952895
char *config_name;
@@ -2915,13 +2915,15 @@ static int module_set_url(int argc, const char **argv, const char *prefix)
29152915
path);
29162916

29172917
config_name = xstrfmt("submodule.%s.url", sub->name);
2918-
config_set_in_gitmodules_file_gently(config_name, newurl);
2918+
ret = config_set_in_gitmodules_file_gently(config_name, newurl);
29192919

2920-
repo_read_gitmodules (the_repository, 0);
2921-
sync_submodule(sub->path, prefix, NULL, quiet ? OPT_QUIET : 0);
2920+
if (!ret) {
2921+
repo_read_gitmodules(the_repository, 0);
2922+
sync_submodule(sub->path, prefix, NULL, quiet ? OPT_QUIET : 0);
2923+
}
29222924

29232925
free(config_name);
2924-
return 0;
2926+
return !!ret;
29252927
}
29262928

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

0 commit comments

Comments
 (0)