summaryrefslogtreecommitdiff
path: root/src/buildtool/file_system/git_tree.cpp
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2025-05-22 17:44:28 +0200
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2025-06-04 14:34:44 +0200
commit1258417cf03b3978005a637c3536873fef146c38 (patch)
treeb7af94dfbf60c7604f51fc717b1a3d035c517c35 /src/buildtool/file_system/git_tree.cpp
parentdb63e5764550fddf0910fb6a7993f2ddb3e6f387 (diff)
downloadjustbuild-1258417cf03b3978005a637c3536873fef146c38.tar.gz
GitTree: Allow tree reading to skip symlinks checker
This is useful when the caller already knows that the tree to look up is valid, and thus the extra check step can be safely skipped.
Diffstat (limited to 'src/buildtool/file_system/git_tree.cpp')
-rw-r--r--src/buildtool/file_system/git_tree.cpp27
1 files changed, 17 insertions, 10 deletions
diff --git a/src/buildtool/file_system/git_tree.cpp b/src/buildtool/file_system/git_tree.cpp
index ca0727fb..3b9f3a8e 100644
--- a/src/buildtool/file_system/git_tree.cpp
+++ b/src/buildtool/file_system/git_tree.cpp
@@ -86,14 +86,19 @@ auto GitTree::Read(std::filesystem::path const& repo_path,
auto GitTree::Read(gsl::not_null<GitCASPtr> const& cas,
std::string const& tree_id,
- bool ignore_special) noexcept -> std::optional<GitTree> {
+ bool ignore_special,
+ bool skip_checks) noexcept -> std::optional<GitTree> {
if (auto raw_id = FromHexString(tree_id)) {
auto repo = GitRepo::Open(cas);
if (repo != std::nullopt) {
- if (auto entries = repo->ReadTree(*raw_id,
- SymlinksChecker{cas},
- /*is_hex_id=*/false,
- ignore_special)) {
+ auto entries =
+ skip_checks ? repo->ReadDirectTree(
+ *raw_id, /*is_hex_id=*/false, ignore_special)
+ : repo->ReadTree(*raw_id,
+ SymlinksChecker{cas},
+ /*is_hex_id=*/false,
+ ignore_special);
+ if (entries) {
// NOTE: the raw_id value is NOT recomputed when
// ignore_special==true.
return GitTree::FromEntries(
@@ -155,11 +160,13 @@ auto GitTreeEntry::Tree(bool ignore_special) const& noexcept
if (repo == std::nullopt) {
return std::nullopt;
}
-
- if (auto entries = repo->ReadTree(raw_id_,
- SymlinksChecker{cas_},
- /*is_hex_id=*/false,
- ignore_special)) {
+ auto entries = repo->ReadTree(raw_id_,
+ SymlinksChecker{cas_},
+ /*is_hex_id=*/false,
+ ignore_special);
+ if (entries) {
+ // NOTE: the raw_id value is NOT recomputed when
+ // ignore_special==true.
return GitTree::FromEntries(
cas_, std::move(*entries), raw_id_, ignore_special);
}