summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2025-06-05 09:55:17 +0200
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2025-06-05 11:51:47 +0200
commit7bc00b40a22f8b925219dc12110693a38cba67e0 (patch)
treed7dc97d9098ae19ab3c8a559d1b8f7b809712d38 /src
parent23a2e73cd0c3d63a4e6f8b9e11b2bcb3da6ecf6e (diff)
downloadjustbuild-7bc00b40a22f8b925219dc12110693a38cba67e0.tar.gz
GitRepo: Ensure compliance with existing noexcept specifiers
...while also removing some unneeded one. Do not implicitly trust that the third-party code called in these methods is non-throwing and instead properly handle any exception that might arise. Also remove the specifiers from some anonymous namespace methods where a try-catch would be overkill and let their callers handle any exceptions instead.
Diffstat (limited to 'src')
-rw-r--r--src/buildtool/file_system/git_repo.cpp24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/buildtool/file_system/git_repo.cpp b/src/buildtool/file_system/git_repo.cpp
index b19dfe3e..d5ae6e3d 100644
--- a/src/buildtool/file_system/git_repo.cpp
+++ b/src/buildtool/file_system/git_repo.cpp
@@ -55,7 +55,7 @@ std::unordered_set<git_filemode_t> const kNonSpecialGitFileModes{
GIT_FILEMODE_BLOB_EXECUTABLE,
GIT_FILEMODE_TREE};
-[[nodiscard]] auto ToHexString(git_oid const& oid) noexcept
+[[nodiscard]] auto ToHexString(git_oid const& oid)
-> std::optional<std::string> {
std::string hex_id(GIT_OID_HEXSZ, '\0');
if (git_oid_fmt(hex_id.data(), &oid) != 0) {
@@ -99,7 +99,7 @@ std::unordered_set<git_filemode_t> const kNonSpecialGitFileModes{
}
}
-[[nodiscard]] auto GitTypeToObjectType(git_object_t const& type) noexcept
+[[nodiscard]] auto GitTypeToObjectType(git_object_t const& type)
-> std::optional<ObjectType> {
switch (type) {
case GIT_OBJECT_BLOB:
@@ -154,8 +154,7 @@ std::unordered_set<git_filemode_t> const kNonSpecialGitFileModes{
[[nodiscard]] auto flat_tree_walker_ignore_special(const char* /*root*/,
const git_tree_entry* entry,
- void* payload) noexcept
- -> int {
+ void* payload) -> int {
auto* entries =
reinterpret_cast<GitRepo::tree_entries_t*>(payload); // NOLINT
@@ -180,7 +179,7 @@ std::unordered_set<git_filemode_t> const kNonSpecialGitFileModes{
[[nodiscard]] auto flat_tree_walker(const char* /*root*/,
const git_tree_entry* entry,
- void* payload) noexcept -> int {
+ void* payload) -> int {
auto* entries =
reinterpret_cast<GitRepo::tree_entries_t*>(payload); // NOLINT
@@ -1640,10 +1639,17 @@ auto GitRepo::LocalFetchViaTmpRepo(StorageConfig const& storage_config,
auto GitRepo::GetConfigSnapshot() const noexcept
-> std::shared_ptr<git_config> {
#ifndef BOOTSTRAP_BUILD_TOOL
- git_config* cfg_ptr{nullptr};
- if (git_repository_config_snapshot(&cfg_ptr, git_cas_->GetRepository()) ==
- 0) {
- return std::shared_ptr<git_config>(cfg_ptr, config_closer);
+ try {
+ git_config* cfg_ptr{nullptr};
+ if (git_repository_config_snapshot(&cfg_ptr,
+ git_cas_->GetRepository()) == 0) {
+ return std::shared_ptr<git_config>(cfg_ptr, config_closer);
+ }
+ } catch (std::exception const& ex) {
+ Logger::Log(
+ LogLevel::Debug,
+ "Unexpected failure getting Git configuration snapshot:\n{}",
+ ex.what());
}
#endif // BOOTSTRAP_BUILD_TOOL
return nullptr;