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:
Patrick Steinhardt
2024-05-17 10:18:34 +02:00
committed by Junio C Hamano
parent f1782d185b
commit 965f8991e5
8 changed files with 33 additions and 21 deletions

View File

@@ -1,6 +1,8 @@
#ifndef REPOSITORY_H
#define REPOSITORY_H
#include "strmap.h"
struct config_set;
struct fsmonitor_settings;
struct git_hash_algo;
@@ -108,6 +110,12 @@ struct repository {
*/
struct ref_store *refs_private;
/*
* A strmap of ref_stores, stored by submodule name, accessible via
* `repo_get_submodule_ref_store()`.
*/
struct strmap submodule_ref_stores;
/*
* Contains path to often used file names.
*/