summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/other_tools/just_mr/setup.cpp4
-rw-r--r--src/other_tools/root_maps/tree_id_git_map.cpp34
-rw-r--r--src/other_tools/root_maps/tree_id_git_map.hpp1
3 files changed, 21 insertions, 18 deletions
diff --git a/src/other_tools/just_mr/setup.cpp b/src/other_tools/just_mr/setup.cpp
index 4f4b6b11..d09f699f 100644
--- a/src/other_tools/just_mr/setup.cpp
+++ b/src/other_tools/just_mr/setup.cpp
@@ -162,8 +162,8 @@ auto MultiRepoSetup(std::shared_ptr<Configuration> const& config,
&import_to_git_map,
&critical_git_op_map,
common_args.jobs);
- auto tree_id_git_map =
- CreateTreeIdGitMap(&git_tree_fetch_map, common_args.jobs);
+ auto tree_id_git_map = CreateTreeIdGitMap(
+ &git_tree_fetch_map, common_args.fetch_absent, common_args.jobs);
auto repos_to_setup_map = CreateReposToSetupMap(config,
main,
interactive,
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 faedccf4..3d5ccf1e 100644
--- a/src/other_tools/root_maps/tree_id_git_map.cpp
+++ b/src/other_tools/root_maps/tree_id_git_map.cpp
@@ -20,14 +20,15 @@
auto CreateTreeIdGitMap(
gsl::not_null<GitTreeFetchMap*> const& git_tree_fetch_map,
+ bool fetch_absent,
std::size_t jobs) -> TreeIdGitMap {
- auto tree_to_git = [git_tree_fetch_map](auto ts,
- auto setter,
- auto logger,
- auto /*unused*/,
- auto const& key) {
- // if root is absent, no work needs to be done
- if (key.absent) {
+ auto tree_to_git = [git_tree_fetch_map, fetch_absent](auto ts,
+ auto setter,
+ auto logger,
+ auto /*unused*/,
+ auto const& key) {
+ // if root is actually absent, no work needs to be done
+ if (key.absent and not fetch_absent) {
auto root = nlohmann::json::array(
{key.ignore_special ? FileRoot::kGitTreeIgnoreSpecialMarker
: FileRoot::kGitTreeMarker,
@@ -35,6 +36,7 @@ auto CreateTreeIdGitMap(
(*setter)(std::pair(std::move(root), false));
return;
}
+ // otherwise, one must fetch;
// make sure the required tree is in Git cache
git_tree_fetch_map->ConsumeAfterKeysReady(
ts,
@@ -43,15 +45,15 @@ auto CreateTreeIdGitMap(
// tree is now in Git cache;
// get cache hit info
auto is_cache_hit = *values[0];
- // set the workspace root
- auto root = nlohmann::json::array(
- {key.ignore_special ? FileRoot::kGitTreeIgnoreSpecialMarker
- : FileRoot::kGitTreeMarker,
- key.tree_info.hash});
- if (not key.absent) {
- root.emplace_back(StorageConfig::GitRoot().string());
- }
- (*setter)(std::pair(std::move(root), is_cache_hit));
+ // set the workspace root as present
+ (*setter)(
+ std::pair(nlohmann::json::array(
+ {key.ignore_special
+ ? FileRoot::kGitTreeIgnoreSpecialMarker
+ : FileRoot::kGitTreeMarker,
+ key.tree_info.hash,
+ StorageConfig::GitRoot().string()}),
+ is_cache_hit));
},
[logger, tree_id = key.tree_info.hash](auto const& msg,
bool fatal) {
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 89d1af08..78dcc982 100644
--- a/src/other_tools/root_maps/tree_id_git_map.hpp
+++ b/src/other_tools/root_maps/tree_id_git_map.hpp
@@ -57,6 +57,7 @@ using TreeIdGitMap =
[[nodiscard]] auto CreateTreeIdGitMap(
gsl::not_null<GitTreeFetchMap*> const& git_tree_fetch_map,
+ bool fetch_absent,
std::size_t jobs) -> TreeIdGitMap;
#endif // INCLUDED_SRC_OTHER_TOOLS_ROOT_MAPS_TREE_ID_GIT_MAP_HPP