From 0afacdb938a9787151f338656fa943679b7ec68b Mon Sep 17 00:00:00 2001 From: Maksim Denisov Date: Wed, 24 Jul 2024 10:16:34 +0200 Subject: Pass SymlinksCheckFunc to GitRepo as not_null + invoke it only if there are symlinks to check + remove the corresponding runtime check since it is replaced by a compile-time check --- src/buildtool/file_system/git_repo.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'src/buildtool/file_system/git_repo.cpp') diff --git a/src/buildtool/file_system/git_repo.cpp b/src/buildtool/file_system/git_repo.cpp index f87f8e6b..346c1c13 100644 --- a/src/buildtool/file_system/git_repo.cpp +++ b/src/buildtool/file_system/git_repo.cpp @@ -1791,7 +1791,7 @@ auto GitRepo::IsRepoFake() const noexcept -> bool { } auto GitRepo::ReadTree(std::string const& id, - SymlinksCheckFunc const& check_symlinks, + gsl::not_null const& check_symlinks, bool is_hex_id, bool ignore_special) const noexcept -> std::optional { @@ -1851,11 +1851,8 @@ auto GitRepo::ReadTree(std::string const& id, } } // we check symlinks in bulk, optimized for network-backed repos - if (not check_symlinks) { - Logger::Log(LogLevel::Debug, "check_symlink callable is empty"); - return std::nullopt; - } - if (not check_symlinks(symlinks)) { + if (not symlinks.empty() and + not std::invoke(check_symlinks.get(), symlinks)) { Logger::Log(LogLevel::Error, "found upwards symlinks in Git tree {}", is_hex_id ? std::string{id} : ToHexString(id)); @@ -1928,11 +1925,11 @@ auto GitRepo::CreateTree(tree_entries_t const& entries) const noexcept #endif } -auto GitRepo::ReadTreeData(std::string const& data, - std::string const& id, - SymlinksCheckFunc const& check_symlinks, - bool is_hex_id) noexcept - -> std::optional { +auto GitRepo::ReadTreeData( + std::string const& data, + std::string const& id, + gsl::not_null const& check_symlinks, + bool is_hex_id) noexcept -> std::optional { #ifndef BOOTSTRAP_BUILD_TOOL try { InMemoryODBBackend b{.parent = kInMemoryODBParent}; -- cgit v1.2.3