]> git.ipfire.org Git - thirdparty/git.git/commitdiff
submodule--helper: return error from set-url when modifying failed
authorJan Alexander Steffens (heftig) <heftig@archlinux.org>
Tue, 3 Oct 2023 18:50:43 +0000 (20:50 +0200)
committerJunio C Hamano <gitster@pobox.com>
Tue, 3 Oct 2023 22:30:43 +0000 (15:30 -0700)
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>
builtin/submodule--helper.c

index 0c1509ad6ed925efb4e1d8e30e786ed1a3b9a7c8..cce46450abe95ea6a24d28026a1686cb930cb75a 100644 (file)
@@ -2889,7 +2889,7 @@ cleanup:
 
 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;
@@ -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)