]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin/submodule--helper.c
submodule--helper: check repo{_submodule,}_init() return values
[thirdparty/git.git] / builtin / submodule--helper.c
index bfcc8e2c9951db9c4058a0de5f1c1f1b7e899d98..7f0a39286fb4ac8e765cc95eeef29d768d841b06 100644 (file)
@@ -63,7 +63,10 @@ static char *get_default_remote_submodule(const char *module_path)
 {
        struct repository subrepo;
 
-       repo_submodule_init(&subrepo, the_repository, module_path, null_oid());
+       if (repo_submodule_init(&subrepo, the_repository, module_path,
+                               null_oid()) < 0)
+               die(_("could not get a repository handle for submodule '%s'"),
+                   module_path);
        return repo_get_default_remote(&subrepo);
 }
 
@@ -1480,7 +1483,9 @@ static int add_possible_reference_from_superproject(
                struct strbuf err = STRBUF_INIT;
                strbuf_add(&sb, odb->path, len);
 
-               repo_init(&alternate, sb.buf, NULL);
+               if (repo_init(&alternate, sb.buf, NULL) < 0)
+                       die(_("could not get a repository handle for gitdir '%s'"),
+                           sb.buf);
 
                /*
                 * We need to end the new path with '/' to mark it as a dir,