refs: pass repo when retrieving submodule ref store
Looking up submodule ref stores has two deficiencies: - The initialized subrepo will be attributed to `the_repository`. - The submodule ref store will be tracked in a global map. This makes it impossible to have submodule ref stores for a repository other than `the_repository`. Modify the function to accept the parent repository as parameter and move the global map into `struct repository`. Like this it becomes possible to look up submodule ref stores for arbitrary repositories. Note that this also adds a new reference to `the_repository` in `resolve_gitlink_ref()`, which is part of the refs interfaces. This will get adjusted in the next patch. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:

committed by
Junio C Hamano

parent
f1782d185b
commit
965f8991e5
@ -14,6 +14,7 @@
|
||||
#include "sparse-index.h"
|
||||
#include "trace2.h"
|
||||
#include "promisor-remote.h"
|
||||
#include "refs.h"
|
||||
|
||||
/* The main repository */
|
||||
static struct repository the_repo;
|
||||
@ -289,6 +290,9 @@ static void repo_clear_path_cache(struct repo_path_cache *cache)
|
||||
|
||||
void repo_clear(struct repository *repo)
|
||||
{
|
||||
struct hashmap_iter iter;
|
||||
struct strmap_entry *e;
|
||||
|
||||
FREE_AND_NULL(repo->gitdir);
|
||||
FREE_AND_NULL(repo->commondir);
|
||||
FREE_AND_NULL(repo->graft_file);
|
||||
@ -329,6 +333,10 @@ void repo_clear(struct repository *repo)
|
||||
FREE_AND_NULL(repo->remote_state);
|
||||
}
|
||||
|
||||
strmap_for_each_entry(&repo->submodule_ref_stores, &iter, e)
|
||||
ref_store_release(e->value);
|
||||
strmap_clear(&repo->submodule_ref_stores, 1);
|
||||
|
||||
repo_clear_path_cache(&repo->cached_paths);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user