diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2024-04-05 11:48:13 +0200 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2024-04-10 14:06:21 +0200 |
commit | 4fe5fc8aec6e391a5e300e234bdc41375bff1d9e (patch) | |
tree | d5eb3cb68f5d44fc89f885667cf6242b0d137a99 /src/other_tools/root_maps/content_git_map.cpp | |
parent | 43ac36b4cd2b6aa0b42219f5920a7b4e72832ae5 (diff) | |
download | justbuild-4fe5fc8aec6e391a5e300e234bdc41375bff1d9e.tar.gz |
resolve_symlinks_map: Allow separate source and target repositories
In certain cases, e.g., on the serve endpoint, an unresolved tree
might lie in a repository other than the Git cache, therefore we
cannot create any new entries there, as it would violate our
guarantee that we only write under our local build root.
Therefore, the resolve_symlinks_map now receives pointers to both
the source and target Git databases and ensures that:
1. any tree created on-the-fly is stored exclusively in the target
repository, and
2. any other entry required for those trees is made available in
the target repository by copying it from the source repository.
Note that in our use case the target repository is always our Git
cache and passing a pointer to that object database is done to
avoid the overhead of otherwise opening the database very often.
Diffstat (limited to 'src/other_tools/root_maps/content_git_map.cpp')
-rw-r--r-- | src/other_tools/root_maps/content_git_map.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/other_tools/root_maps/content_git_map.cpp b/src/other_tools/root_maps/content_git_map.cpp index 2a6cad56..d3b0e35b 100644 --- a/src/other_tools/root_maps/content_git_map.cpp +++ b/src/other_tools/root_maps/content_git_map.cpp @@ -171,6 +171,7 @@ void EnsureRootAsAbsent( void ResolveContentTree( ArchiveRepoInfo const& key, std::string const& tree_hash, + GitCASPtr const& just_git_cas, bool is_cache_hit, bool is_absent, bool serve_api_exists, @@ -212,13 +213,15 @@ void ResolveContentTree( } } else { - // resolve tree + // resolve tree; both source and target repos are the Git cache resolve_symlinks_map->ConsumeAfterKeysReady( ts, {GitObjectToResolve(tree_hash, ".", *key.pragma_special, - /*known_info=*/std::nullopt)}, + /*known_info=*/std::nullopt, + just_git_cas, + just_git_cas)}, [resolve_symlinks_map, tree_hash, tree_id_file, @@ -357,6 +360,7 @@ void WriteIdFileAndSetWSRoot( // resolve tree and set workspace root ResolveContentTree(key, *subtree_hash, + just_git_cas, false, /*is_cache_hit*/ is_absent, serve_api_exists, @@ -543,6 +547,7 @@ auto CreateContentGitMap( ResolveContentTree( key, *subtree_hash, + op_result.git_cas, /*is_cache_hit = */ true, /*is_absent = */ (key.absent and not fetch_absent), serve_api_exists, |