summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2025-05-09 12:58:17 +0200
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2025-06-04 14:34:44 +0200
commitecb6a45bf6d97000519b567d2e5269fffce780dd (patch)
treed947debc53778ff0d1b61f3af82d758730795df3
parent314e28ee1a357a9b256e3c6c528c8a8a18989880 (diff)
downloadjustbuild-ecb6a45bf6d97000519b567d2e5269fffce780dd.tar.gz
git_cas: Be explicit in hash type (raw or hex) when reading
-rw-r--r--src/buildtool/file_system/git_cas.hpp4
-rw-r--r--src/buildtool/file_system/git_repo.cpp2
-rw-r--r--src/buildtool/file_system/git_tree.cpp10
-rw-r--r--src/buildtool/file_system/symlinks/resolve_symlinks_map.cpp3
4 files changed, 10 insertions, 9 deletions
diff --git a/src/buildtool/file_system/git_cas.hpp b/src/buildtool/file_system/git_cas.hpp
index 5c5a3f31..299f7a2f 100644
--- a/src/buildtool/file_system/git_cas.hpp
+++ b/src/buildtool/file_system/git_cas.hpp
@@ -68,7 +68,7 @@ class GitCAS {
/// \param log_failure Log level at which to log failures accessing the
/// object.
[[nodiscard]] auto ReadObject(std::string const& id,
- bool is_hex_id = false,
+ bool is_hex_id,
LogLevel log_failure = LogLevel::Warning)
const noexcept -> std::optional<std::string>;
@@ -79,7 +79,7 @@ class GitCAS {
// Note that most backends do not support reading only the header of an
// object, so the whole object will be read and then the header will be
// returned.
- [[nodiscard]] auto ReadHeader(std::string const& id, bool is_hex_id = false)
+ [[nodiscard]] auto ReadHeader(std::string const& id, bool is_hex_id)
const noexcept -> std::optional<std::pair<std::size_t, ObjectType>>;
private:
diff --git a/src/buildtool/file_system/git_repo.cpp b/src/buildtool/file_system/git_repo.cpp
index c711510c..d63626a2 100644
--- a/src/buildtool/file_system/git_repo.cpp
+++ b/src/buildtool/file_system/git_repo.cpp
@@ -137,7 +137,7 @@ std::unordered_set<git_filemode_t> const kNonSpecialGitFileModes{
return std::all_of(entries.begin(), entries.end(), [cas](auto entry) {
auto const& [id, nodes] = entry;
// if CAS given, check that the entry is in the object database
- if (cas != nullptr and not cas->ReadHeader(id)) {
+ if (cas != nullptr and not cas->ReadHeader(id, /*is_hex_id=*/false)) {
return false;
}
// for a given raw id, either all entries are trees or none of them
diff --git a/src/buildtool/file_system/git_tree.cpp b/src/buildtool/file_system/git_tree.cpp
index 3d1418f1..ded027c2 100644
--- a/src/buildtool/file_system/git_tree.cpp
+++ b/src/buildtool/file_system/git_tree.cpp
@@ -124,21 +124,21 @@ auto GitTree::LookupEntryByPath(
}
auto GitTree::Size() const noexcept -> std::optional<std::size_t> {
- if (auto header = cas_->ReadHeader(raw_id_)) {
+ if (auto header = cas_->ReadHeader(raw_id_, /*is_hex_id=*/false)) {
return header->first;
}
return std::nullopt;
}
auto GitTree::RawData() const noexcept -> std::optional<std::string> {
- return cas_->ReadObject(raw_id_);
+ return cas_->ReadObject(raw_id_, /*is_hex_id=*/false);
}
auto GitTreeEntry::Blob() const noexcept -> std::optional<std::string> {
if (not IsBlob()) {
return std::nullopt;
}
- return cas_->ReadObject(raw_id_);
+ return cas_->ReadObject(raw_id_, /*is_hex_id=*/false);
}
auto GitTreeEntry::Tree(bool ignore_special) const& noexcept
@@ -164,12 +164,12 @@ auto GitTreeEntry::Tree(bool ignore_special) const& noexcept
}
auto GitTreeEntry::Size() const noexcept -> std::optional<std::size_t> {
- if (auto header = cas_->ReadHeader(raw_id_)) {
+ if (auto header = cas_->ReadHeader(raw_id_, /*is_hex_id=*/false)) {
return header->first;
}
return std::nullopt;
}
auto GitTreeEntry::RawData() const noexcept -> std::optional<std::string> {
- return cas_->ReadObject(raw_id_);
+ return cas_->ReadObject(raw_id_, /*is_hex_id=*/false);
}
diff --git a/src/buildtool/file_system/symlinks/resolve_symlinks_map.cpp b/src/buildtool/file_system/symlinks/resolve_symlinks_map.cpp
index d55ee19d..ddd266fa 100644
--- a/src/buildtool/file_system/symlinks/resolve_symlinks_map.cpp
+++ b/src/buildtool/file_system/symlinks/resolve_symlinks_map.cpp
@@ -154,7 +154,8 @@ void ResolveKnownEntry(GitObjectToResolve const& obj,
obj.pragma_special != PragmaSpecial::Ignore) {
// children info is known, so pass this forward
if (IsSymlinkObject(e.type)) {
- if (auto target = obj.source_cas->ReadObject(raw_id)) {
+ if (auto target = obj.source_cas->ReadObject(
+ raw_id, /*is_hex_id=*/false)) {
children_info.emplace_back(
obj.root_tree_id,
obj.rel_path / e.name,