summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-01-15 17:20:17 +0100
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-01-26 14:51:43 +0100
commit395c0c8cffc97ae6e29f12715bb5496db121ae01 (patch)
tree2bcfb43128495f08f68c9a0a7fce36b724f3fe38 /src
parent577db2f76dfd6d8d5c5dba53adeff3f64c631086 (diff)
downloadjustbuild-395c0c8cffc97ae6e29f12715bb5496db121ae01.tar.gz
just-mr 'git' repository: Fix wrong witnessing repo when remote CAS provides tree
When the remote CAS provides the root tree, we perform an import-to-git operation, therefore the correct witnessing repository for the tree should always be the Git cache.
Diffstat (limited to 'src')
-rw-r--r--src/other_tools/root_maps/commit_git_map.cpp42
1 files changed, 32 insertions, 10 deletions
diff --git a/src/other_tools/root_maps/commit_git_map.cpp b/src/other_tools/root_maps/commit_git_map.cpp
index 7855c3f2..0461f474 100644
--- a/src/other_tools/root_maps/commit_git_map.cpp
+++ b/src/other_tools/root_maps/commit_git_map.cpp
@@ -259,7 +259,7 @@ void EnsureCommit(GitRepoInfo const& repo_info,
"tree {} for absent commit {}",
*root_tree_id,
repo_info.hash),
- true);
+ /*fatal=*/true);
return;
}
if (not local_api->RetrieveToPaths(
@@ -271,7 +271,7 @@ void EnsureCommit(GitRepoInfo const& repo_info,
"tree {} to {}",
*root_tree_id,
tmp_dir->GetPath().string()),
- true);
+ /*fatal=*/true);
return;
}
CommitInfo c_info{
@@ -293,16 +293,38 @@ void EnsureCommit(GitRepoInfo const& repo_info,
/*fatal=*/true);
return;
}
+ // sanity check: we should get the expected tree
+ if (values[0]->first != root_tree_id) {
+ (*logger)(
+ fmt::format("Unexpected mismatch in "
+ "imported git tree id: "
+ "expected {}, but got {}",
+ root_tree_id,
+ values[0]->first),
+ /*fatal=*/true);
+ return;
+ }
+ // tree is now in Git cache
+ auto just_git_cas =
+ GitCAS::Open(StorageConfig::GitRoot());
+ if (not just_git_cas) {
+ (*logger)(
+ "Could not open Git cache object "
+ "database!",
+ /*fatal=*/true);
+ return;
+ }
// write association to id file, get subdir
// tree, and set the workspace root
- WriteIdFileAndSetWSRoot(root_tree_id,
- subdir,
- ignore_special,
- git_cas,
- repo_root,
- tree_id_file,
- ws_setter,
- logger);
+ WriteIdFileAndSetWSRoot(
+ root_tree_id,
+ subdir,
+ ignore_special,
+ just_git_cas,
+ StorageConfig::GitRoot(),
+ tree_id_file,
+ ws_setter,
+ logger);
},
[logger, tmp_dir, root_tree_id](auto const& msg,
bool fatal) {