From 01ffd4d9a5f824a74b0e86750e9145fb623ccbcd Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Wed, 15 Nov 2023 17:45:12 +0100 Subject: git tree repository: Creating absent roots should not run the command Also extended absent-roots test with this scenario. --- src/other_tools/root_maps/tree_id_git_map.cpp | 11 +++++++++- test/end-to-end/just-mr/absent-roots.sh | 31 +++++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 1 deletion(-) 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 ce2fe5e5..752f224d 100644 --- a/src/other_tools/root_maps/tree_id_git_map.cpp +++ b/src/other_tools/root_maps/tree_id_git_map.cpp @@ -96,7 +96,16 @@ auto CreateTreeIdGitMap( auto logger, auto /*unused*/, auto const& key) { - // first, check whether tree exists already in CAS + // if root is absent, no work needs to be done + if (key.absent) { + auto root = nlohmann::json::array( + {key.ignore_special ? FileRoot::kGitTreeIgnoreSpecialMarker + : FileRoot::kGitTreeMarker, + key.hash}); + (*setter)(std::pair(std::move(root), false)); + return; + } + // check whether tree exists already in CAS // ensure Git cache // define Git operation to be done GitOpKey op_key = {.params = diff --git a/test/end-to-end/just-mr/absent-roots.sh b/test/end-to-end/just-mr/absent-roots.sh index 7f3154a6..ad4846e1 100644 --- a/test/end-to-end/just-mr/absent-roots.sh +++ b/test/end-to-end/just-mr/absent-roots.sh @@ -109,4 +109,35 @@ test $(jq -r '.repositories.test.workspace_root | length' "${CONF}") = 2 # Check the tree was correctly set via 'just serve' remote test "$(jq -r '.repositories.test.workspace_root[1]' "${CONF}")" = "${GIT_ROOT_ID}" +# Now check that an absent git tree repository works without running the command +rm -rf "${LBR}" + +cat > repos.json <