summaryrefslogtreecommitdiff
path: root/src/other_tools/root_maps/commit_git_map.cpp
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-01-29 16:27:40 +0100
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2024-01-31 17:15:44 +0100
commit3dc81b4b5a89f4e37af45ec9954723c79c3017cf (patch)
treeb3f18bca1a29e3ff88013f282e6fb0efdd09aea9 /src/other_tools/root_maps/commit_git_map.cpp
parentc1827db24dbc8f0d6eca47c92f34d85bf6b2b128 (diff)
downloadjustbuild-3dc81b4b5a89f4e37af45ec9954723c79c3017cf.tar.gz
serve source tree: Increase server-side granularity in response statuses
For archives and Git repositories we should ensure that not finding the witnessing entity (archive content blob or Git commit, respectively) results in a distinct status in the response to a request that sets up roots on the serve endpoint. This will allow just-mr to better handle its interaction with the serve endpoint.
Diffstat (limited to 'src/other_tools/root_maps/commit_git_map.cpp')
-rw-r--r--src/other_tools/root_maps/commit_git_map.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/other_tools/root_maps/commit_git_map.cpp b/src/other_tools/root_maps/commit_git_map.cpp
index c39df472..63cfa02a 100644
--- a/src/other_tools/root_maps/commit_git_map.cpp
+++ b/src/other_tools/root_maps/commit_git_map.cpp
@@ -689,9 +689,9 @@ void EnsureCommit(
fatal);
});
// get tree id and return workspace root
- auto subtree = git_repo->GetSubtreeFromCommit(
+ auto res = git_repo->GetSubtreeFromCommit(
repo_info.hash, repo_info.subdir, wrapped_logger);
- if (not subtree) {
+ if (not std::holds_alternative<std::string>(res)) {
return;
}
// set the workspace root as present
@@ -701,7 +701,7 @@ void EnsureCommit(
{repo_info.ignore_special
? FileRoot::kGitTreeIgnoreSpecialMarker
: FileRoot::kGitTreeMarker,
- *subtree,
+ std::get<std::string>(res), // subtree id
repo_root}),
/*is_cache_hit=*/false));
},
@@ -724,15 +724,16 @@ void EnsureCommit(
fatal);
});
// get tree id and return workspace root
- auto subtree = git_repo->GetSubtreeFromCommit(
+ auto res = git_repo->GetSubtreeFromCommit(
repo_info.hash, repo_info.subdir, wrapped_logger);
- if (not subtree) {
+ if (not std::holds_alternative<std::string>(res)) {
return;
}
+ auto subtree = std::get<std::string>(res);
// set the workspace root
if (repo_info.absent and not fetch_absent) {
// try by all available means to generate and set the absent root
- EnsureRootAsAbsent(*subtree,
+ EnsureRootAsAbsent(subtree,
repo_root,
repo_info,
serve_api_exists,
@@ -747,7 +748,7 @@ void EnsureCommit(
{repo_info.ignore_special
? FileRoot::kGitTreeIgnoreSpecialMarker
: FileRoot::kGitTreeMarker,
- *subtree,
+ subtree,
repo_root.string()}),
/*is_cache_hit=*/true));
}