]> git.ipfire.org Git - thirdparty/git.git/blobdiff - repository.c
submodule: extract path to submodule gitdir func
[thirdparty/git.git] / repository.c
index 448cd557d4cf80fe9d1d81785676b08358082039..710a3b4bf872fb0db64f859d5c49d085c198f089 100644 (file)
@@ -11,6 +11,7 @@
 #include "lockfile.h"
 #include "submodule-config.h"
 #include "sparse-index.h"
+#include "promisor-remote.h"
 
 /* The main repository */
 static struct repository the_repo;
@@ -172,6 +173,10 @@ int repo_init(struct repository *repo,
 
        repo_set_hash_algo(repo, format.hash_algo);
 
+       /* take ownership of format.partial_clone */
+       repo->repository_format_partial_clone = format.partial_clone;
+       format.partial_clone = NULL;
+
        if (worktree)
                repo_set_worktree(repo, worktree);
 
@@ -208,8 +213,7 @@ int repo_submodule_init(struct repository *subrepo,
                 * submodule would not have a worktree.
                 */
                strbuf_reset(&gitdir);
-               strbuf_repo_git_path(&gitdir, superproject,
-                                    "modules/%s", sub->name);
+               submodule_name_to_gitdir(&gitdir, superproject, sub->name);
 
                if (repo_init(subrepo, gitdir.buf, NULL)) {
                        ret = -1;
@@ -258,6 +262,11 @@ void repo_clear(struct repository *repo)
                if (repo->index != &the_index)
                        FREE_AND_NULL(repo->index);
        }
+
+       if (repo->promisor_remote_config) {
+               promisor_remote_clear(repo->promisor_remote_config);
+               FREE_AND_NULL(repo->promisor_remote_config);
+       }
 }
 
 int repo_read_index(struct repository *repo)