summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/buildtool/build_engine/target_map/absent_target_map.cpp7
-rw-r--r--src/buildtool/build_engine/target_map/export.cpp2
-rw-r--r--src/buildtool/build_engine/target_map/target_map.cpp2
-rw-r--r--src/buildtool/main/analyse_context.hpp2
-rw-r--r--src/buildtool/main/describe.cpp6
-rw-r--r--src/buildtool/main/describe.hpp2
-rw-r--r--src/buildtool/main/main.cpp14
-rw-r--r--src/buildtool/serve_api/remote/serve_api.hpp23
-rw-r--r--src/buildtool/serve_api/serve_service/serve_server_implementation.cpp7
-rw-r--r--src/buildtool/serve_api/serve_service/serve_server_implementation.hpp2
-rw-r--r--src/buildtool/serve_api/serve_service/target.hpp6
-rw-r--r--src/other_tools/just_mr/TARGETS2
-rw-r--r--src/other_tools/just_mr/fetch.cpp16
-rw-r--r--src/other_tools/just_mr/setup.cpp16
-rw-r--r--src/other_tools/ops_maps/content_cas_map.cpp8
-rw-r--r--src/other_tools/ops_maps/content_cas_map.hpp2
-rw-r--r--src/other_tools/ops_maps/git_tree_fetch_map.cpp8
-rw-r--r--src/other_tools/ops_maps/git_tree_fetch_map.hpp2
-rw-r--r--src/other_tools/root_maps/commit_git_map.cpp32
-rw-r--r--src/other_tools/root_maps/commit_git_map.hpp2
-rw-r--r--src/other_tools/root_maps/content_git_map.cpp50
-rw-r--r--src/other_tools/root_maps/content_git_map.hpp2
-rw-r--r--src/other_tools/root_maps/distdir_git_map.cpp26
-rw-r--r--src/other_tools/root_maps/distdir_git_map.hpp2
-rw-r--r--src/other_tools/root_maps/foreign_file_git_map.cpp17
-rw-r--r--src/other_tools/root_maps/foreign_file_git_map.hpp2
-rw-r--r--src/other_tools/root_maps/fpath_git_map.cpp22
-rw-r--r--src/other_tools/root_maps/fpath_git_map.hpp2
-rw-r--r--src/other_tools/root_maps/tree_id_git_map.cpp16
-rw-r--r--src/other_tools/root_maps/tree_id_git_map.hpp2
30 files changed, 145 insertions, 157 deletions
diff --git a/src/buildtool/build_engine/target_map/absent_target_map.cpp b/src/buildtool/build_engine/target_map/absent_target_map.cpp
index 18251de3..b21f426c 100644
--- a/src/buildtool/build_engine/target_map/absent_target_map.cpp
+++ b/src/buildtool/build_engine/target_map/absent_target_map.cpp
@@ -86,7 +86,7 @@ void WithFlexibleVariables(
task,
key.target.ToString());
context->progress->TaskTracker().Start(task);
- auto res = (*context->serve)->ServeTarget(*target_cache_key, *repo_key);
+ auto res = context->serve->ServeTarget(*target_cache_key, *repo_key);
// process response from serve endpoint
if (not res) {
// report target not found
@@ -203,9 +203,8 @@ auto BuildMaps::Target::CreateAbsentTargetVariablesMap(
auto key) {
std::optional<std::vector<std::string>> vars;
if (context->serve) {
- vars = (*context->serve)
- ->ServeTargetVariables(
- key.target_root_id, key.target_file, key.target);
+ vars = context->serve->ServeTargetVariables(
+ key.target_root_id, key.target_file, key.target);
}
if (not vars) {
diff --git a/src/buildtool/build_engine/target_map/export.cpp b/src/buildtool/build_engine/target_map/export.cpp
index ea600fc7..23a70cd4 100644
--- a/src/buildtool/build_engine/target_map/export.cpp
+++ b/src/buildtool/build_engine/target_map/export.cpp
@@ -152,7 +152,7 @@ void ExportRule(
PruneJson(effective_config.ToJson()).dump());
context->progress->TaskTracker().Start(task);
auto res =
- (*context->serve)->ServeTarget(*target_cache_key, *repo_key);
+ context->serve->ServeTarget(*target_cache_key, *repo_key);
// process response from serve endpoint
if (not res) {
// target not found: log to performance, and continue
diff --git a/src/buildtool/build_engine/target_map/target_map.cpp b/src/buildtool/build_engine/target_map/target_map.cpp
index 8df7abbf..c474596a 100644
--- a/src/buildtool/build_engine/target_map/target_map.cpp
+++ b/src/buildtool/build_engine/target_map/target_map.cpp
@@ -1914,7 +1914,7 @@ auto CreateTargetMap(
/*is_fatal=*/true);
return;
}
- if (not(*context->serve)->CheckServeRemoteExecution()) {
+ if (not context->serve->CheckServeRemoteExecution()) {
(*logger)(
"Inconsistent remote execution endpoint and serve endpoint"
"configuration detected.",
diff --git a/src/buildtool/main/analyse_context.hpp b/src/buildtool/main/analyse_context.hpp
index 0702410c..d5022d4b 100644
--- a/src/buildtool/main/analyse_context.hpp
+++ b/src/buildtool/main/analyse_context.hpp
@@ -29,7 +29,7 @@ struct AnalyseContext final {
ActiveTargetCache const& target_cache;
gsl::not_null<Statistics*> statistics;
gsl::not_null<Progress*> progress;
- std::optional<gsl::not_null<const ServeApi*>> serve;
+ std::optional<ServeApi> const& serve;
};
#endif // INCLUDED_SRC_BUILDOOL_MAIN_ANALYSE_CONTEXT_HPP
diff --git a/src/buildtool/main/describe.cpp b/src/buildtool/main/describe.cpp
index 467d382a..978adadb 100644
--- a/src/buildtool/main/describe.cpp
+++ b/src/buildtool/main/describe.cpp
@@ -267,7 +267,7 @@ auto DescribeUserDefinedRule(
auto DescribeTarget(BuildMaps::Target::ConfiguredTarget const& id,
gsl::not_null<const RepositoryConfig*> const& repo_config,
- std::optional<gsl::not_null<const ServeApi*>> const& serve,
+ std::optional<ServeApi> const& serve,
std::size_t jobs,
bool print_json) -> int {
#ifndef BOOTSTRAP_BUILD_TOOL
@@ -285,7 +285,7 @@ auto DescribeTarget(BuildMaps::Target::ConfiguredTarget const& id,
// check that just serve and the client use same remote execution
// endpoint; it might make sense in the future to remove or avoid this
// check, e.g., if remote endpoints are behind proxies.
- if (not(*serve)->CheckServeRemoteExecution()) {
+ if (not serve->CheckServeRemoteExecution()) {
Logger::Log(LogLevel::Error,
"Inconsistent remote execution endpoint and serve "
"endpoint configuration detected.");
@@ -302,7 +302,7 @@ auto DescribeTarget(BuildMaps::Target::ConfiguredTarget const& id,
repo_name);
return kExitFailure;
}
- if (auto dgst = (*serve)->ServeTargetDescription(
+ if (auto dgst = serve->ServeTargetDescription(
*target_root_id,
*(repo_config->TargetFileName(repo_name)),
id.target.GetNamedTarget().name)) {
diff --git a/src/buildtool/main/describe.hpp b/src/buildtool/main/describe.hpp
index 3548e40f..1d116801 100644
--- a/src/buildtool/main/describe.hpp
+++ b/src/buildtool/main/describe.hpp
@@ -26,7 +26,7 @@
[[nodiscard]] auto DescribeTarget(
BuildMaps::Target::ConfiguredTarget const& id,
gsl::not_null<const RepositoryConfig*> const& repo_config,
- std::optional<gsl::not_null<const ServeApi*>> const& serve,
+ std::optional<ServeApi> const& serve,
std::size_t jobs,
bool print_json) -> int;
diff --git a/src/buildtool/main/main.cpp b/src/buildtool/main/main.cpp
index 0063e9bd..bdd1bed5 100644
--- a/src/buildtool/main/main.cpp
+++ b/src/buildtool/main/main.cpp
@@ -867,11 +867,7 @@ auto main(int argc, char* argv[]) -> int {
if (arguments.cmd == SubCommand::kServe) {
SetupServeServiceConfig(arguments.service);
- std::optional<gsl::not_null<const ServeApi*>> serve;
- if (RemoteServeConfig::Instance().RemoteAddress()) {
- serve = &ServeApi::Instance();
- }
-
+ auto serve = ServeApi::Create(RemoteServeConfig::Instance());
if (!ServeServerImpl::Instance().Run(
RemoteServeConfig::Instance(),
serve,
@@ -956,12 +952,10 @@ auto main(int argc, char* argv[]) -> int {
DetermineRoots(&repo_config, arguments.common, arguments.analysis);
#ifndef BOOTSTRAP_BUILD_TOOL
- std::optional<gsl::not_null<const ServeApi*>> serve;
- if (RemoteServeConfig::Instance().RemoteAddress()) {
- serve = &ServeApi::Instance();
- }
+ std::optional<ServeApi> serve =
+ ServeApi::Create(RemoteServeConfig::Instance());
#else
- std::optional<gsl::not_null<const ServeApi*>> serve;
+ std::optional<ServeApi> serve;
#endif // BOOTSTRAP_BUILD_TOOL
#ifndef BOOTSTRAP_BUILD_TOOL
diff --git a/src/buildtool/serve_api/remote/serve_api.hpp b/src/buildtool/serve_api/remote/serve_api.hpp
index 98966e6a..510881cb 100644
--- a/src/buildtool/serve_api/remote/serve_api.hpp
+++ b/src/buildtool/serve_api/remote/serve_api.hpp
@@ -37,10 +37,8 @@ class ServeApi final {};
class ServeApi final {
public:
- [[nodiscard]] static auto Instance() noexcept -> ServeApi const& {
- static ServeApi instance = ServeApi::init();
- return instance;
- }
+ explicit ServeApi(ServerAddress const& address) noexcept
+ : stc_{address}, tc_{address}, cc_{address} {}
~ServeApi() noexcept = default;
ServeApi(ServeApi const&) = delete;
@@ -48,6 +46,15 @@ class ServeApi final {
auto operator=(ServeApi const&) -> ServeApi& = delete;
auto operator=(ServeApi&&) -> ServeApi& = delete;
+ [[nodiscard]] static auto Create(
+ RemoteServeConfig const& serve_config) noexcept
+ -> std::optional<ServeApi> {
+ if (auto address = serve_config.RemoteAddress()) {
+ return std::make_optional<ServeApi>(*address);
+ }
+ return std::nullopt;
+ }
+
[[nodiscard]] auto RetrieveTreeFromCommit(std::string const& commit,
std::string const& subdir = ".",
bool sync_tree = false)
@@ -130,14 +137,6 @@ class ServeApi final {
}
private:
- explicit ServeApi(ServerAddress const& address) noexcept
- : stc_{address}, tc_{address}, cc_{address} {}
-
- [[nodiscard]] static auto init() noexcept -> ServeApi {
- auto sadd = RemoteServeConfig::Instance().RemoteAddress();
- return ServeApi{*sadd};
- }
-
// source tree service client
SourceTreeClient const stc_;
// target service client
diff --git a/src/buildtool/serve_api/serve_service/serve_server_implementation.cpp b/src/buildtool/serve_api/serve_service/serve_server_implementation.cpp
index b8b092f8..b588fc45 100644
--- a/src/buildtool/serve_api/serve_service/serve_server_implementation.cpp
+++ b/src/buildtool/serve_api/serve_service/serve_server_implementation.cpp
@@ -60,10 +60,9 @@ auto TryWrite(std::string const& file, T const& content) noexcept -> bool {
}
} // namespace
-auto ServeServerImpl::Run(
- RemoteServeConfig const& serve_config,
- std::optional<gsl::not_null<const ServeApi*>> const& serve,
- bool with_execute) -> bool {
+auto ServeServerImpl::Run(RemoteServeConfig const& serve_config,
+ std::optional<ServeApi> const& serve,
+ bool with_execute) -> bool {
// make sure the git root directory is properly initialized
if (not FileSystemManager::CreateDirectory(StorageConfig::GitRoot())) {
Logger::Log(LogLevel::Error,
diff --git a/src/buildtool/serve_api/serve_service/serve_server_implementation.hpp b/src/buildtool/serve_api/serve_service/serve_server_implementation.hpp
index f9eea2f6..b3c0ee51 100644
--- a/src/buildtool/serve_api/serve_service/serve_server_implementation.hpp
+++ b/src/buildtool/serve_api/serve_service/serve_server_implementation.hpp
@@ -55,7 +55,7 @@ class ServeServerImpl {
/// \param with_execute Flag specifying if just serve should act also as
/// just execute (i.e., start remote execution services with same interface)
auto Run(RemoteServeConfig const& serve_config,
- std::optional<gsl::not_null<const ServeApi*>> const& serve,
+ std::optional<ServeApi> const& serve,
bool with_execute) -> bool;
~ServeServerImpl() = default;
diff --git a/src/buildtool/serve_api/serve_service/target.hpp b/src/buildtool/serve_api/serve_service/target.hpp
index 7e94c919..171ac42b 100644
--- a/src/buildtool/serve_api/serve_service/target.hpp
+++ b/src/buildtool/serve_api/serve_service/target.hpp
@@ -40,8 +40,8 @@
class TargetService final : public justbuild::just_serve::Target::Service {
public:
TargetService(RemoteServeConfig const& serve_config,
- std::optional<gsl::not_null<const ServeApi*>> serve) noexcept
- : serve_config_{serve_config}, serve_(std::move(serve)) {}
+ std::optional<ServeApi> const& serve) noexcept
+ : serve_config_{serve_config}, serve_(serve) {}
// Given a target-level caching key, returns the computed value. In doing
// so, it can build on the associated endpoint passing the
@@ -120,7 +120,7 @@ class TargetService final : public justbuild::just_serve::Target::Service {
private:
RemoteServeConfig const& serve_config_;
- std::optional<gsl::not_null<const ServeApi*>> serve_;
+ std::optional<ServeApi> const& serve_;
std::shared_ptr<Logger> logger_{std::make_shared<Logger>("target-service")};
// type of dispatch list; reduces verbosity
diff --git a/src/other_tools/just_mr/TARGETS b/src/other_tools/just_mr/TARGETS
index ff2af01f..b6c6022a 100644
--- a/src/other_tools/just_mr/TARGETS
+++ b/src/other_tools/just_mr/TARGETS
@@ -110,7 +110,6 @@
, "stage": ["src", "other_tools", "just_mr"]
, "private-deps":
[ ["@", "fmt", "", "fmt"]
- , ["@", "gsl", "", "gsl"]
, ["@", "json", "", "json"]
, ["src/buildtool/logging", "logging"]
, ["src/buildtool/multithreading", "task_system"]
@@ -160,7 +159,6 @@
, "stage": ["src", "other_tools", "just_mr"]
, "private-deps":
[ ["@", "json", "", "json"]
- , ["@", "gsl", "", "gsl"]
, ["src/buildtool/logging", "logging"]
, ["src/buildtool/multithreading", "task_system"]
, ["src/buildtool/storage", "fs_utils"]
diff --git a/src/other_tools/just_mr/fetch.cpp b/src/other_tools/just_mr/fetch.cpp
index 99fd9f62..ebba56e5 100644
--- a/src/other_tools/just_mr/fetch.cpp
+++ b/src/other_tools/just_mr/fetch.cpp
@@ -19,7 +19,6 @@
#include <utility> // std::move
#include "fmt/core.h"
-#include "gsl/gsl"
#include "nlohmann/json.hpp"
#include "src/buildtool/execution_api/common/execution_api.hpp"
#include "src/buildtool/execution_api/local/local_api.hpp"
@@ -402,23 +401,24 @@ auto MultiRepoFetch(std::shared_ptr<Configuration> const& config,
bool remote_compatible{common_args.compatible == true};
// setup the API for serving roots
- std::optional<gsl::not_null<const ServeApi*>> serve;
- if (JustMR::Utils::SetupServeApi(common_args.remote_serve_address,
- auth_args)) {
- serve = &ServeApi::Instance();
- }
+ bool serve_api_exists = JustMR::Utils::SetupServeApi(
+ common_args.remote_serve_address, auth_args);
+
+ auto serve = serve_api_exists
+ ? ServeApi::Create(RemoteServeConfig::Instance())
+ : std::nullopt;
// check configuration of the serve endpoint provided
if (serve) {
// if we have a remote endpoint explicitly given by the user, it must
// match what the serve endpoint expects
if (remote_api and common_args.remote_execution_address and
- not(*serve)->CheckServeRemoteExecution()) {
+ not serve->CheckServeRemoteExecution()) {
return kExitFetchError; // this check logs error on failure
}
// check the compatibility mode of the serve endpoint
- auto compatible = (*serve)->IsCompatible();
+ auto compatible = serve->IsCompatible();
if (not compatible) {
Logger::Log(LogLevel::Warning,
"Checking compatibility configuration of the provided "
diff --git a/src/other_tools/just_mr/setup.cpp b/src/other_tools/just_mr/setup.cpp
index b0d530f2..47993e34 100644
--- a/src/other_tools/just_mr/setup.cpp
+++ b/src/other_tools/just_mr/setup.cpp
@@ -20,7 +20,6 @@
#include <exception>
#include <thread>
-#include "gsl/gsl"
#include "nlohmann/json.hpp"
#include "src/buildtool/execution_api/common/execution_api.hpp"
#include "src/buildtool/execution_api/local/local_api.hpp"
@@ -120,23 +119,24 @@ auto MultiRepoSetup(std::shared_ptr<Configuration> const& config,
bool remote_compatible{common_args.compatible == true};
// setup the API for serving roots
- std::optional<gsl::not_null<const ServeApi*>> serve;
- if (JustMR::Utils::SetupServeApi(common_args.remote_serve_address,
- auth_args)) {
- serve = &ServeApi::Instance();
- }
+ bool serve_api_exists = JustMR::Utils::SetupServeApi(
+ common_args.remote_serve_address, auth_args);
+
+ auto serve = serve_api_exists
+ ? ServeApi::Create(RemoteServeConfig::Instance())
+ : std::nullopt;
// check configuration of the serve endpoint provided
if (serve) {
// if we have a remote endpoint explicitly given by the user, it must
// match what the serve endpoint expects
if (remote_api and common_args.remote_execution_address and
- not(*serve)->CheckServeRemoteExecution()) {
+ not serve->CheckServeRemoteExecution()) {
return std::nullopt; // this check logs error on failure
}
// check the compatibility mode of the serve endpoint
- auto compatible = (*serve)->IsCompatible();
+ auto compatible = serve->IsCompatible();
if (not compatible) {
Logger::Log(LogLevel::Warning,
"Checking compatibility configuration of the provided "
diff --git a/src/other_tools/ops_maps/content_cas_map.cpp b/src/other_tools/ops_maps/content_cas_map.cpp
index 527bd7de..97e959d4 100644
--- a/src/other_tools/ops_maps/content_cas_map.cpp
+++ b/src/other_tools/ops_maps/content_cas_map.cpp
@@ -108,7 +108,7 @@ auto CreateContentCASMap(
MirrorsPtr const& additional_mirrors,
CAInfoPtr const& ca_info,
gsl::not_null<CriticalGitOpMap*> const& critical_git_op_map,
- std::optional<gsl::not_null<const ServeApi*>> const& serve,
+ std::optional<ServeApi> const& serve,
gsl::not_null<IExecutionApi*> const& local_api,
std::optional<gsl::not_null<IExecutionApi*>> const& remote_api,
std::size_t jobs) -> ContentCASMap {
@@ -116,7 +116,7 @@ auto CreateContentCASMap(
additional_mirrors,
ca_info,
critical_git_op_map,
- serve,
+ &serve,
local_api,
remote_api](auto ts,
auto setter,
@@ -149,7 +149,7 @@ auto CreateContentCASMap(
just_mr_paths,
additional_mirrors,
ca_info,
- serve,
+ &serve,
local_api,
remote_api,
setter,
@@ -216,7 +216,7 @@ auto CreateContentCASMap(
}
// check if content is known to remote serve service
if (serve and remote_api and
- (*serve)->ContentInRemoteCAS(key.content)) {
+ serve->ContentInRemoteCAS(key.content)) {
// try to get content from remote CAS
if (remote_api.value()->RetrieveToCas(
{Artifact::ObjectInfo{.digest = digest,
diff --git a/src/other_tools/ops_maps/content_cas_map.hpp b/src/other_tools/ops_maps/content_cas_map.hpp
index 9e8d9f46..0fb66970 100644
--- a/src/other_tools/ops_maps/content_cas_map.hpp
+++ b/src/other_tools/ops_maps/content_cas_map.hpp
@@ -84,7 +84,7 @@ using ContentCASMap = AsyncMapConsumer<ArchiveContent, std::nullptr_t>;
MirrorsPtr const& additional_mirrors,
CAInfoPtr const& ca_info,
gsl::not_null<CriticalGitOpMap*> const& critical_git_op_map,
- std::optional<gsl::not_null<const ServeApi*>> const& serve,
+ std::optional<ServeApi> const& serve,
gsl::not_null<IExecutionApi*> const& local_api,
std::optional<gsl::not_null<IExecutionApi*>> const& remote_api,
std::size_t jobs) -> ContentCASMap;
diff --git a/src/other_tools/ops_maps/git_tree_fetch_map.cpp b/src/other_tools/ops_maps/git_tree_fetch_map.cpp
index 10095045..b99c7814 100644
--- a/src/other_tools/ops_maps/git_tree_fetch_map.cpp
+++ b/src/other_tools/ops_maps/git_tree_fetch_map.cpp
@@ -128,7 +128,7 @@ auto CreateGitTreeFetchMap(
gsl::not_null<ImportToGitMap*> const& import_to_git_map,
std::string const& git_bin,
std::vector<std::string> const& launcher,
- std::optional<gsl::not_null<const ServeApi*>> const& serve,
+ std::optional<ServeApi> const& serve,
gsl::not_null<IExecutionApi*> const& local_api,
std::optional<gsl::not_null<IExecutionApi*>> const& remote_api,
bool backup_to_remote,
@@ -137,7 +137,7 @@ auto CreateGitTreeFetchMap(
import_to_git_map,
git_bin,
launcher,
- serve,
+ &serve,
local_api,
remote_api,
backup_to_remote](auto ts,
@@ -163,7 +163,7 @@ auto CreateGitTreeFetchMap(
import_to_git_map,
git_bin,
launcher,
- serve,
+ &serve,
local_api,
remote_api,
backup_to_remote,
@@ -235,7 +235,7 @@ auto CreateGitTreeFetchMap(
// as we anyway interrogate the remote execution endpoint,
// we're only interested here in the serve endpoint making
// an attempt to upload the tree, if known, to remote CAS
- std::ignore = (*serve)->TreeInRemoteCAS(key.hash);
+ std::ignore = serve->TreeInRemoteCAS(key.hash);
}
// check if tree is in remote CAS, if a remote is given
if (remote_api and
diff --git a/src/other_tools/ops_maps/git_tree_fetch_map.hpp b/src/other_tools/ops_maps/git_tree_fetch_map.hpp
index 3f6e6769..93ca450f 100644
--- a/src/other_tools/ops_maps/git_tree_fetch_map.hpp
+++ b/src/other_tools/ops_maps/git_tree_fetch_map.hpp
@@ -60,7 +60,7 @@ using GitTreeFetchMap = AsyncMapConsumer<GitTreeInfo, bool>;
gsl::not_null<ImportToGitMap*> const& import_to_git_map,
std::string const& git_bin,
std::vector<std::string> const& launcher,
- std::optional<gsl::not_null<const ServeApi*>> const& serve,
+ std::optional<ServeApi> const& serve,
gsl::not_null<IExecutionApi*> const& local_api,
std::optional<gsl::not_null<IExecutionApi*>> const& remote_api,
bool backup_to_remote,
diff --git a/src/other_tools/root_maps/commit_git_map.cpp b/src/other_tools/root_maps/commit_git_map.cpp
index fc77e9e7..78a116ae 100644
--- a/src/other_tools/root_maps/commit_git_map.cpp
+++ b/src/other_tools/root_maps/commit_git_map.cpp
@@ -62,14 +62,14 @@ void EnsureRootAsAbsent(
std::string const& tree_id,
std::filesystem::path const& repo_root,
GitRepoInfo const& repo_info,
- std::optional<gsl::not_null<const ServeApi*>> const& serve,
+ std::optional<ServeApi> const& serve,
std::optional<gsl::not_null<IExecutionApi*>> const& remote_api,
CommitGitMap::SetterPtr const& ws_setter,
CommitGitMap::LoggerPtr const& logger) {
// this is an absent root
if (serve) {
// check if the serve endpoint has this root
- auto has_tree = CheckServeHasAbsentRoot(**serve, tree_id, logger);
+ auto has_tree = CheckServeHasAbsentRoot(*serve, tree_id, logger);
if (not has_tree) {
return;
}
@@ -77,9 +77,9 @@ void EnsureRootAsAbsent(
// try to see if serve endpoint has the information to prepare the
// root itself
auto serve_result =
- (*serve)->RetrieveTreeFromCommit(repo_info.hash,
- repo_info.subdir,
- /*sync_tree = */ false);
+ serve->RetrieveTreeFromCommit(repo_info.hash,
+ repo_info.subdir,
+ /*sync_tree = */ false);
if (std::holds_alternative<std::string>(serve_result)) {
// if serve has set up the tree, it must match what we expect
auto const& served_tree_id =
@@ -115,7 +115,7 @@ void EnsureRootAsAbsent(
}
// the tree is known locally, so we can upload it to remote CAS
// for the serve endpoint to retrieve it and set up the root
- if (not EnsureAbsentRootOnServe(**serve,
+ if (not EnsureAbsentRootOnServe(*serve,
tree_id,
repo_root,
&(*remote_api.value()),
@@ -411,7 +411,7 @@ void EnsureCommit(
gsl::not_null<ImportToGitMap*> const& import_to_git_map,
std::string const& git_bin,
std::vector<std::string> const& launcher,
- std::optional<gsl::not_null<const ServeApi*>> const& serve,
+ std::optional<ServeApi> const& serve,
gsl::not_null<IExecutionApi*> const& local_api,
std::optional<gsl::not_null<IExecutionApi*>> const& remote_api,
bool fetch_absent,
@@ -514,9 +514,9 @@ void EnsureCommit(
// if root purely absent, request only the subdir tree
if (repo_info.absent and not fetch_absent) {
auto serve_result =
- (*serve)->RetrieveTreeFromCommit(repo_info.hash,
- repo_info.subdir,
- /*sync_tree = */ false);
+ serve->RetrieveTreeFromCommit(repo_info.hash,
+ repo_info.subdir,
+ /*sync_tree = */ false);
if (std::holds_alternative<std::string>(serve_result)) {
// set the workspace root as absent
JustMRProgress::Instance().TaskTracker().Stop(
@@ -545,9 +545,9 @@ void EnsureCommit(
// we maintain the id file association
else {
auto serve_result =
- (*serve)->RetrieveTreeFromCommit(repo_info.hash,
- /*subdir = */ ".",
- /*sync_tree = */ true);
+ serve->RetrieveTreeFromCommit(repo_info.hash,
+ /*subdir = */ ".",
+ /*sync_tree = */ true);
if (std::holds_alternative<std::string>(serve_result)) {
auto const& root_tree_id =
std::get<std::string>(serve_result);
@@ -923,7 +923,7 @@ auto CreateCommitGitMap(
MirrorsPtr const& additional_mirrors,
std::string const& git_bin,
std::vector<std::string> const& launcher,
- std::optional<gsl::not_null<const ServeApi*>> const& serve,
+ std::optional<ServeApi> const& serve,
gsl::not_null<IExecutionApi*> const& local_api,
std::optional<gsl::not_null<IExecutionApi*>> const& remote_api,
bool fetch_absent,
@@ -934,7 +934,7 @@ auto CreateCommitGitMap(
additional_mirrors,
git_bin,
launcher,
- serve,
+ &serve,
local_api,
remote_api,
fetch_absent](auto ts,
@@ -975,7 +975,7 @@ auto CreateCommitGitMap(
import_to_git_map,
git_bin,
launcher,
- serve,
+ &serve,
local_api,
remote_api,
fetch_absent,
diff --git a/src/other_tools/root_maps/commit_git_map.hpp b/src/other_tools/root_maps/commit_git_map.hpp
index 1f2ff707..4cdc7fd9 100644
--- a/src/other_tools/root_maps/commit_git_map.hpp
+++ b/src/other_tools/root_maps/commit_git_map.hpp
@@ -81,7 +81,7 @@ using CommitGitMap =
MirrorsPtr const& additional_mirrors,
std::string const& git_bin,
std::vector<std::string> const& launcher,
- std::optional<gsl::not_null<const ServeApi*>> const& serve,
+ std::optional<ServeApi> const& serve,
gsl::not_null<IExecutionApi*> const& local_api,
std::optional<gsl::not_null<IExecutionApi*>> const& remote_api,
bool fetch_absent,
diff --git a/src/other_tools/root_maps/content_git_map.cpp b/src/other_tools/root_maps/content_git_map.cpp
index 6fccb871..f014a227 100644
--- a/src/other_tools/root_maps/content_git_map.cpp
+++ b/src/other_tools/root_maps/content_git_map.cpp
@@ -55,7 +55,7 @@ namespace {
void EnsureRootAsAbsent(
std::string const& tree_id,
ArchiveRepoInfo const& key,
- std::optional<gsl::not_null<const ServeApi*>> const& serve,
+ std::optional<ServeApi> const& serve,
std::optional<gsl::not_null<IExecutionApi*>> const& remote_api,
bool is_cache_hit,
ContentGitMap::SetterPtr const& ws_setter,
@@ -63,7 +63,7 @@ void EnsureRootAsAbsent(
// this is an absent root
if (serve) {
// check if the serve endpoint has this root
- auto has_tree = CheckServeHasAbsentRoot(**serve, tree_id, logger);
+ auto has_tree = CheckServeHasAbsentRoot(*serve, tree_id, logger);
if (not has_tree) {
return;
}
@@ -72,11 +72,11 @@ void EnsureRootAsAbsent(
// root itself; this is redundant if root is not already cached
if (is_cache_hit) {
auto serve_result =
- (*serve)->RetrieveTreeFromArchive(key.archive.content,
- key.repo_type,
- key.subdir,
- key.pragma_special,
- /*sync_tree=*/false);
+ serve->RetrieveTreeFromArchive(key.archive.content,
+ key.repo_type,
+ key.subdir,
+ key.pragma_special,
+ /*sync_tree=*/false);
if (std::holds_alternative<std::string>(serve_result)) {
// if serve has set up the tree, it must match what we
// expect
@@ -117,7 +117,7 @@ void EnsureRootAsAbsent(
// CAS for the serve endpoint to retrieve it and set up the
// root
if (not EnsureAbsentRootOnServe(
- **serve,
+ *serve,
tree_id,
StorageConfig::GitRoot(),
&(*remote_api.value()),
@@ -142,7 +142,7 @@ void EnsureRootAsAbsent(
// the tree is known locally, so we can upload it to remote
// CAS for the serve endpoint to retrieve it and set up the
// root
- if (not EnsureAbsentRootOnServe(**serve,
+ if (not EnsureAbsentRootOnServe(*serve,
tree_id,
StorageConfig::GitRoot(),
&(*remote_api.value()),
@@ -175,7 +175,7 @@ void ResolveContentTree(
GitCASPtr const& just_git_cas,
bool is_cache_hit,
bool is_absent,
- std::optional<gsl::not_null<const ServeApi*>> const& serve,
+ std::optional<ServeApi> const& serve,
std::optional<gsl::not_null<IExecutionApi*>> const& remote_api,
gsl::not_null<CriticalGitOpMap*> const& critical_git_op_map,
gsl::not_null<ResolveSymlinksMap*> const& resolve_symlinks_map,
@@ -231,7 +231,7 @@ void ResolveContentTree(
is_cache_hit,
key,
is_absent,
- serve,
+ &serve,
remote_api,
ts,
ws_setter,
@@ -273,7 +273,7 @@ void ResolveContentTree(
key,
tree_id_file,
is_absent,
- serve,
+ &serve,
remote_api,
is_cache_hit,
ws_setter,
@@ -364,7 +364,7 @@ void WriteIdFileAndSetWSRoot(
GitCASPtr const& just_git_cas,
std::filesystem::path const& archive_tree_id_file,
bool is_absent,
- std::optional<gsl::not_null<const ServeApi*>> const& serve,
+ std::optional<ServeApi> const& serve,
std::optional<gsl::not_null<IExecutionApi*>> const& remote_api,
gsl::not_null<CriticalGitOpMap*> const& critical_git_op_map,
gsl::not_null<ResolveSymlinksMap*> const& resolve_symlinks_map,
@@ -425,7 +425,7 @@ void ExtractAndImportToGit(
std::filesystem::path const& content_cas_path,
std::filesystem::path const& archive_tree_id_file,
bool is_absent,
- std::optional<gsl::not_null<const ServeApi*>> const& serve,
+ std::optional<ServeApi> const& serve,
std::optional<gsl::not_null<IExecutionApi*>> const& remote_api,
gsl::not_null<CriticalGitOpMap*> const& critical_git_op_map,
gsl::not_null<ImportToGitMap*> const& import_to_git_map,
@@ -461,7 +461,7 @@ void ExtractAndImportToGit(
archive_tree_id_file,
key,
is_absent,
- serve,
+ &serve,
remote_api,
critical_git_op_map,
resolve_symlinks_map,
@@ -509,7 +509,7 @@ auto CreateContentGitMap(
CAInfoPtr const& ca_info,
gsl::not_null<ResolveSymlinksMap*> const& resolve_symlinks_map,
gsl::not_null<CriticalGitOpMap*> const& critical_git_op_map,
- std::optional<gsl::not_null<const ServeApi*>> const& serve,
+ std::optional<ServeApi> const& serve,
std::optional<gsl::not_null<IExecutionApi*>> const& remote_api,
bool fetch_absent,
std::size_t jobs) -> ContentGitMap {
@@ -520,7 +520,7 @@ auto CreateContentGitMap(
just_mr_paths,
additional_mirrors,
ca_info,
- serve,
+ &serve,
remote_api,
fetch_absent](auto ts,
auto setter,
@@ -556,7 +556,7 @@ auto CreateContentGitMap(
[archive_tree_id = *archive_tree_id,
key,
fetch_absent,
- serve,
+ &serve,
remote_api,
critical_git_op_map,
resolve_symlinks_map,
@@ -624,12 +624,12 @@ auto CreateContentGitMap(
// request the resolved subdir tree from the serve endpoint, if
// given
if (serve) {
- auto serve_result = (*serve)->RetrieveTreeFromArchive(
- key.archive.content,
- key.repo_type,
- key.subdir,
- key.pragma_special,
- /*sync_tree = */ false);
+ auto serve_result =
+ serve->RetrieveTreeFromArchive(key.archive.content,
+ key.repo_type,
+ key.subdir,
+ key.pragma_special,
+ /*sync_tree = */ false);
if (std::holds_alternative<std::string>(serve_result)) {
// set the workspace root as absent
JustMRProgress::Instance().TaskTracker().Stop(
@@ -702,7 +702,7 @@ auto CreateContentGitMap(
just_mr_paths,
additional_mirrors,
ca_info,
- serve,
+ &serve,
remote_api,
ts,
setter,
diff --git a/src/other_tools/root_maps/content_git_map.hpp b/src/other_tools/root_maps/content_git_map.hpp
index 06759ec8..12623440 100644
--- a/src/other_tools/root_maps/content_git_map.hpp
+++ b/src/other_tools/root_maps/content_git_map.hpp
@@ -43,7 +43,7 @@ using ContentGitMap =
CAInfoPtr const& ca_info,
gsl::not_null<ResolveSymlinksMap*> const& resolve_symlinks_map,
gsl::not_null<CriticalGitOpMap*> const& critical_git_op_map,
- std::optional<gsl::not_null<const ServeApi*>> const& serve,
+ std::optional<ServeApi> const& serve,
std::optional<gsl::not_null<IExecutionApi*>> const& remote_api,
bool fetch_absent,
std::size_t jobs) -> ContentGitMap;
diff --git a/src/other_tools/root_maps/distdir_git_map.cpp b/src/other_tools/root_maps/distdir_git_map.cpp
index 2caa4b74..afd83ba6 100644
--- a/src/other_tools/root_maps/distdir_git_map.cpp
+++ b/src/other_tools/root_maps/distdir_git_map.cpp
@@ -132,14 +132,14 @@ auto CreateDistdirGitMap(
gsl::not_null<ContentCASMap*> const& content_cas_map,
gsl::not_null<ImportToGitMap*> const& import_to_git_map,
gsl::not_null<CriticalGitOpMap*> const& critical_git_op_map,
- std::optional<gsl::not_null<const ServeApi*>> const& serve,
+ std::optional<ServeApi> const& serve,
gsl::not_null<IExecutionApi*> const& local_api,
std::optional<gsl::not_null<IExecutionApi*>> const& remote_api,
std::size_t jobs) -> DistdirGitMap {
auto distdir_to_git = [content_cas_map,
import_to_git_map,
critical_git_op_map,
- serve,
+ &serve,
local_api,
remote_api](auto ts,
auto setter,
@@ -175,7 +175,7 @@ auto CreateDistdirGitMap(
[distdir_tree_id = *distdir_tree_id,
content_id = key.content_id,
key,
- serve,
+ &serve,
remote_api,
setter,
logger](auto const& values) {
@@ -192,7 +192,7 @@ auto CreateDistdirGitMap(
if (serve) {
// check if serve endpoint has this root
auto has_tree = CheckServeHasAbsentRoot(
- **serve, distdir_tree_id, logger);
+ *serve, distdir_tree_id, logger);
if (not has_tree) {
return;
}
@@ -200,7 +200,7 @@ auto CreateDistdirGitMap(
// try to see if serve endpoint has the
// information to prepare the root itself
auto serve_result =
- (*serve)->RetrieveTreeFromDistdir(
+ serve->RetrieveTreeFromDistdir(
key.content_list,
/*sync_tree=*/false);
if (std::holds_alternative<std::string>(
@@ -251,7 +251,7 @@ auto CreateDistdirGitMap(
// it to remote CAS for the serve endpoint
// to retrieve it and set up the root
if (not EnsureAbsentRootOnServe(
- **serve,
+ *serve,
distdir_tree_id,
StorageConfig::GitRoot(),
&(*remote_api.value()),
@@ -334,7 +334,7 @@ auto CreateDistdirGitMap(
if (serve) {
// first check if serve endpoint has tree
auto has_tree =
- CheckServeHasAbsentRoot(**serve, tree_id, logger);
+ CheckServeHasAbsentRoot(*serve, tree_id, logger);
if (not has_tree) {
return;
}
@@ -349,8 +349,8 @@ auto CreateDistdirGitMap(
// try to see if serve endpoint has the information to
// prepare the root itself
auto serve_result =
- (*serve)->RetrieveTreeFromDistdir(key.content_list,
- /*sync_tree=*/false);
+ serve->RetrieveTreeFromDistdir(key.content_list,
+ /*sync_tree=*/false);
if (std::holds_alternative<std::string>(serve_result)) {
// if serve has set up the tree, it must match what we
// expect
@@ -398,7 +398,7 @@ auto CreateDistdirGitMap(
// tell serve to set up the root from the remote CAS
// tree; upload can be skipped
if (EnsureAbsentRootOnServe(
- **serve,
+ *serve,
tree_id,
/*repo_path=*/"",
/*remote_api=*/std::nullopt,
@@ -435,7 +435,7 @@ auto CreateDistdirGitMap(
// tell serve to set up the root from the remote CAS
// tree; upload can be skipped
if (EnsureAbsentRootOnServe(
- **serve,
+ *serve,
tree_id,
/*repo_path=*/"",
/*remote_api=*/std::nullopt,
@@ -485,8 +485,8 @@ auto CreateDistdirGitMap(
// a present root, a corresponding remote endpoint is needed
if (serve and remote_api) {
auto serve_result =
- (*serve)->RetrieveTreeFromDistdir(key.content_list,
- /*sync_tree=*/true);
+ serve->RetrieveTreeFromDistdir(key.content_list,
+ /*sync_tree=*/true);
if (std::holds_alternative<std::string>(serve_result)) {
// if serve has set up the tree, it must match what we
// expect
diff --git a/src/other_tools/root_maps/distdir_git_map.hpp b/src/other_tools/root_maps/distdir_git_map.hpp
index d26c80e9..b6413e26 100644
--- a/src/other_tools/root_maps/distdir_git_map.hpp
+++ b/src/other_tools/root_maps/distdir_git_map.hpp
@@ -54,7 +54,7 @@ using DistdirGitMap =
gsl::not_null<ContentCASMap*> const& content_cas_map,
gsl::not_null<ImportToGitMap*> const& import_to_git_map,
gsl::not_null<CriticalGitOpMap*> const& critical_git_op_map,
- std::optional<gsl::not_null<const ServeApi*>> const& serve,
+ std::optional<ServeApi> const& serve,
gsl::not_null<IExecutionApi*> const& local_api,
std::optional<gsl::not_null<IExecutionApi*>> const& remote_api,
std::size_t jobs) -> DistdirGitMap;
diff --git a/src/other_tools/root_maps/foreign_file_git_map.cpp b/src/other_tools/root_maps/foreign_file_git_map.cpp
index 7a2d60dd..9a69ef8e 100644
--- a/src/other_tools/root_maps/foreign_file_git_map.cpp
+++ b/src/other_tools/root_maps/foreign_file_git_map.cpp
@@ -112,11 +112,10 @@ void UseCacheHit(const std::string& tree_id,
/*is_cache_hit=*/true));
}
-void HandleAbsentForeignFile(
- ForeignFileInfo const& key,
- std::optional<gsl::not_null<const ServeApi*>> const& serve,
- ForeignFileGitMap::SetterPtr const& setter,
- ForeignFileGitMap::LoggerPtr const& logger) {
+void HandleAbsentForeignFile(ForeignFileInfo const& key,
+ std::optional<ServeApi> const& serve,
+ ForeignFileGitMap::SetterPtr const& setter,
+ ForeignFileGitMap::LoggerPtr const& logger) {
// Compute tree in memory
GitRepo::tree_entries_t entries{};
auto raw_id = FromHexString(key.archive.content);
@@ -139,7 +138,7 @@ void HandleAbsentForeignFile(
}
auto tree_id = ToHexString(tree->first);
if (serve) {
- auto has_tree = CheckServeHasAbsentRoot(**serve, tree_id, logger);
+ auto has_tree = CheckServeHasAbsentRoot(*serve, tree_id, logger);
if (not has_tree) {
return;
}
@@ -149,7 +148,7 @@ void HandleAbsentForeignFile(
/*is_cache_hit=*/false));
return;
}
- auto serve_result = (*serve)->RetrieveTreeFromForeignFile(
+ auto serve_result = serve->RetrieveTreeFromForeignFile(
key.archive.content, key.name, key.executable);
if (std::holds_alternative<std::string>(serve_result)) {
// if serve has set up the tree, it must match what we
@@ -196,11 +195,11 @@ void HandleAbsentForeignFile(
[[nodiscard]] auto CreateForeignFileGitMap(
gsl::not_null<ContentCASMap*> const& content_cas_map,
gsl::not_null<ImportToGitMap*> const& import_to_git_map,
- std::optional<gsl::not_null<const ServeApi*>> const& serve,
+ std::optional<ServeApi> const& serve,
bool fetch_absent,
std::size_t jobs) -> ForeignFileGitMap {
auto setup_foreign_file =
- [content_cas_map, import_to_git_map, fetch_absent, serve](
+ [content_cas_map, import_to_git_map, fetch_absent, &serve](
auto ts,
auto setter,
auto logger,
diff --git a/src/other_tools/root_maps/foreign_file_git_map.hpp b/src/other_tools/root_maps/foreign_file_git_map.hpp
index bc5f3c01..2cf34df1 100644
--- a/src/other_tools/root_maps/foreign_file_git_map.hpp
+++ b/src/other_tools/root_maps/foreign_file_git_map.hpp
@@ -34,7 +34,7 @@ using ForeignFileGitMap =
[[nodiscard]] auto CreateForeignFileGitMap(
gsl::not_null<ContentCASMap*> const& content_cas_map,
gsl::not_null<ImportToGitMap*> const& import_to_git_map,
- std::optional<gsl::not_null<const ServeApi*>> const& serve,
+ std::optional<ServeApi> const& serve,
bool fetch_absent,
std::size_t jobs) -> ForeignFileGitMap;
diff --git a/src/other_tools/root_maps/fpath_git_map.cpp b/src/other_tools/root_maps/fpath_git_map.cpp
index 913c3db7..6fa4b183 100644
--- a/src/other_tools/root_maps/fpath_git_map.cpp
+++ b/src/other_tools/root_maps/fpath_git_map.cpp
@@ -37,7 +37,7 @@ void CheckServeAndSetRoot(
std::string const& tree_id,
std::string const& repo_root,
bool absent,
- std::optional<gsl::not_null<const ServeApi*>> const& serve,
+ std::optional<ServeApi> const& serve,
std::optional<gsl::not_null<IExecutionApi*>> const& remote_api,
FilePathGitMap::SetterPtr const& ws_setter,
FilePathGitMap::LoggerPtr const& logger) {
@@ -45,7 +45,7 @@ void CheckServeAndSetRoot(
// be able to build against it. If root is not absent, do not fail if we
// don't have a suitable remote endpoint, but warn user nonetheless.
if (serve) {
- auto has_tree = CheckServeHasAbsentRoot(**serve, tree_id, logger);
+ auto has_tree = CheckServeHasAbsentRoot(*serve, tree_id, logger);
if (not has_tree) {
return; // fatal
}
@@ -63,7 +63,7 @@ void CheckServeAndSetRoot(
}
}
else {
- if (not EnsureAbsentRootOnServe(**serve,
+ if (not EnsureAbsentRootOnServe(*serve,
tree_id,
repo_root,
&(*remote_api.value()),
@@ -101,7 +101,7 @@ void ResolveFilePathTree(
bool absent,
gsl::not_null<CriticalGitOpMap*> const& critical_git_op_map,
gsl::not_null<ResolveSymlinksMap*> const& resolve_symlinks_map,
- std::optional<gsl::not_null<const ServeApi*>> const& serve,
+ std::optional<ServeApi> const& serve,
std::optional<gsl::not_null<IExecutionApi*>> const& remote_api,
gsl::not_null<TaskSystem*> const& ts,
FilePathGitMap::SetterPtr const& ws_setter,
@@ -146,7 +146,7 @@ void ResolveFilePathTree(
tree_hash,
tree_id_file,
absent,
- serve,
+ &serve,
remote_api,
ts,
ws_setter,
@@ -187,7 +187,7 @@ void ResolveFilePathTree(
[resolved_tree_id,
tree_id_file,
absent,
- serve,
+ &serve,
remote_api,
ws_setter,
logger](auto const& values) {
@@ -255,7 +255,7 @@ auto CreateFilePathGitMap(
gsl::not_null<CriticalGitOpMap*> const& critical_git_op_map,
gsl::not_null<ImportToGitMap*> const& import_to_git_map,
gsl::not_null<ResolveSymlinksMap*> const& resolve_symlinks_map,
- std::optional<gsl::not_null<const ServeApi*>> const& serve,
+ std::optional<ServeApi> const& serve,
std::optional<gsl::not_null<IExecutionApi*>> const& remote_api,
std::size_t jobs,
std::string multi_repo_tool_name,
@@ -264,7 +264,7 @@ auto CreateFilePathGitMap(
critical_git_op_map,
import_to_git_map,
resolve_symlinks_map,
- serve,
+ &serve,
remote_api,
multi_repo_tool_name,
build_tool_name](auto ts,
@@ -303,7 +303,7 @@ auto CreateFilePathGitMap(
repo_root = std::move(*repo_root),
critical_git_op_map,
resolve_symlinks_map,
- serve,
+ &serve,
remote_api,
ts,
setter,
@@ -363,7 +363,7 @@ auto CreateFilePathGitMap(
absent,
critical_git_op_map,
resolve_symlinks_map,
- serve,
+ &serve,
remote_api,
ts,
setter,
@@ -452,7 +452,7 @@ auto CreateFilePathGitMap(
absent = key.absent,
critical_git_op_map,
resolve_symlinks_map,
- serve,
+ &serve,
remote_api,
ts,
setter,
diff --git a/src/other_tools/root_maps/fpath_git_map.hpp b/src/other_tools/root_maps/fpath_git_map.hpp
index 362b5a4b..fbe20a13 100644
--- a/src/other_tools/root_maps/fpath_git_map.hpp
+++ b/src/other_tools/root_maps/fpath_git_map.hpp
@@ -54,7 +54,7 @@ using FilePathGitMap = AsyncMapConsumer<FpathInfo, nlohmann::json>;
gsl::not_null<CriticalGitOpMap*> const& critical_git_op_map,
gsl::not_null<ImportToGitMap*> const& import_to_git_map,
gsl::not_null<ResolveSymlinksMap*> const& resolve_symlinks_map,
- std::optional<gsl::not_null<const ServeApi*>> const& serve,
+ std::optional<ServeApi> const& serve,
std::optional<gsl::not_null<IExecutionApi*>> const& remote_api,
std::size_t jobs,
std::string multi_repo_tool_name,
diff --git a/src/other_tools/root_maps/tree_id_git_map.cpp b/src/other_tools/root_maps/tree_id_git_map.cpp
index 3bdb56e9..bf6d0913 100644
--- a/src/other_tools/root_maps/tree_id_git_map.cpp
+++ b/src/other_tools/root_maps/tree_id_git_map.cpp
@@ -147,7 +147,7 @@ auto CreateTreeIdGitMap(
gsl::not_null<CriticalGitOpMap*> const& critical_git_op_map,
gsl::not_null<ImportToGitMap*> const& import_to_git_map,
bool fetch_absent,
- std::optional<gsl::not_null<const ServeApi*>> const& serve,
+ std::optional<ServeApi> const& serve,
gsl::not_null<IExecutionApi*> const& local_api,
std::optional<gsl::not_null<IExecutionApi*>> const& remote_api,
std::size_t jobs) -> TreeIdGitMap {
@@ -155,7 +155,7 @@ auto CreateTreeIdGitMap(
critical_git_op_map,
import_to_git_map,
fetch_absent,
- serve,
+ &serve,
local_api,
remote_api](auto ts,
auto setter,
@@ -169,8 +169,8 @@ auto CreateTreeIdGitMap(
if (key.absent and not fetch_absent) {
if (serve) {
// check serve endpoint
- auto has_tree = CheckServeHasAbsentRoot(
- **serve, key.tree_info.hash, logger);
+ auto has_tree =
+ CheckServeHasAbsentRoot(*serve, key.tree_info.hash, logger);
if (not has_tree) {
return;
}
@@ -200,7 +200,7 @@ auto CreateTreeIdGitMap(
if (remote_api.value()->IsAvailable({digest})) {
// tell serve to set up the root from the remote CAS tree;
// upload can be skipped
- if (EnsureAbsentRootOnServe(**serve,
+ if (EnsureAbsentRootOnServe(*serve,
key.tree_info.hash,
/*repo_path=*/"",
/*remote_api=*/std::nullopt,
@@ -238,7 +238,7 @@ auto CreateTreeIdGitMap(
critical_git_op_map->ConsumeAfterKeysReady(
ts,
{std::move(op_key)},
- [serve,
+ [&serve,
digest,
import_to_git_map,
local_api,
@@ -286,7 +286,7 @@ auto CreateTreeIdGitMap(
// upload tree from Git cache to remote CAS and tell
// serve to set up the root from the remote CAS
// tree, then set root as absent
- UploadToServeAndSetRoot(**serve,
+ UploadToServeAndSetRoot(*serve,
key.tree_info.hash,
digest,
*remote_api,
@@ -301,7 +301,7 @@ auto CreateTreeIdGitMap(
if (auto path = cas.TreePath(digest)) {
// Move tree locally from CAS to Git cache, then
// continue processing it by UploadToServeAndSetRoot
- MoveCASTreeToGitAndProcess(**serve,
+ MoveCASTreeToGitAndProcess(*serve,
key.tree_info.hash,
digest,
import_to_git_map,
diff --git a/src/other_tools/root_maps/tree_id_git_map.hpp b/src/other_tools/root_maps/tree_id_git_map.hpp
index 52b306a0..0d9611e4 100644
--- a/src/other_tools/root_maps/tree_id_git_map.hpp
+++ b/src/other_tools/root_maps/tree_id_git_map.hpp
@@ -69,7 +69,7 @@ using TreeIdGitMap =
gsl::not_null<CriticalGitOpMap*> const& critical_git_op_map,
gsl::not_null<ImportToGitMap*> const& import_to_git_map,
bool fetch_absent,
- std::optional<gsl::not_null<const ServeApi*>> const& serve,
+ std::optional<ServeApi> const& serve,
gsl::not_null<IExecutionApi*> const& local_api,
std::optional<gsl::not_null<IExecutionApi*>> const& remote_api,
std::size_t jobs) -> TreeIdGitMap;