diff options
-rw-r--r-- | src/buildtool/file_system/git_repo.cpp | 18 | ||||
-rw-r--r-- | src/other_tools/git_operations/TARGETS | 1 | ||||
-rw-r--r-- | src/other_tools/git_operations/git_repo_remote.cpp | 19 |
3 files changed, 16 insertions, 22 deletions
diff --git a/src/buildtool/file_system/git_repo.cpp b/src/buildtool/file_system/git_repo.cpp index 98dcb1fd..09a60c2e 100644 --- a/src/buildtool/file_system/git_repo.cpp +++ b/src/buildtool/file_system/git_repo.cpp @@ -333,21 +333,17 @@ struct FetchIntoODBBackend { [[maybe_unused]] git_odb* odb, git_indexer_progress_cb progress_cb, void* progress_payload) -> int { - if (_backend != nullptr) { - auto* b = reinterpret_cast<FetchIntoODBBackend*>(_backend); // NOLINT - return git_odb_write_pack( - _writepack, b->target_odb, progress_cb, progress_payload); - } - return GIT_ERROR; + Ensures(_backend != nullptr); + auto* b = reinterpret_cast<FetchIntoODBBackend*>(_backend); // NOLINT + return git_odb_write_pack( + _writepack, b->target_odb, progress_cb, progress_payload); } [[nodiscard]] auto fetch_backend_exists(git_odb_backend* _backend, const git_oid* oid) -> int { - if (_backend != nullptr) { - auto* b = reinterpret_cast<FetchIntoODBBackend*>(_backend); // NOLINT - return git_odb_exists(b->target_odb, oid); - } - return GIT_ERROR; + Ensures(_backend != nullptr); + auto* b = reinterpret_cast<FetchIntoODBBackend*>(_backend); // NOLINT + return git_odb_exists(b->target_odb, oid); } void fetch_backend_free(git_odb_backend* /*_backend*/) {} diff --git a/src/other_tools/git_operations/TARGETS b/src/other_tools/git_operations/TARGETS index 7605c94e..68889001 100644 --- a/src/other_tools/git_operations/TARGETS +++ b/src/other_tools/git_operations/TARGETS @@ -35,6 +35,7 @@ , "private-deps": [ "git_config_settings" , ["@", "fmt", "", "fmt"] + , ["@", "gsl", "", "gsl"] , ["@", "json", "", "json"] , ["", "libgit2"] , ["src/buildtool/file_system", "file_system_manager"] diff --git a/src/other_tools/git_operations/git_repo_remote.cpp b/src/other_tools/git_operations/git_repo_remote.cpp index ffbb0222..9635863e 100644 --- a/src/other_tools/git_operations/git_repo_remote.cpp +++ b/src/other_tools/git_operations/git_repo_remote.cpp @@ -23,6 +23,7 @@ #include <utility> // std::move #include "fmt/core.h" +#include "gsl/gsl" #include "nlohmann/json.hpp" #include "src/buildtool/file_system/file_system_manager.hpp" #include "src/buildtool/file_system/git_utils.hpp" @@ -64,21 +65,17 @@ struct FetchIntoODBBackend { [[maybe_unused]] git_odb* odb, git_indexer_progress_cb progress_cb, void* progress_payload) -> int { - if (_backend != nullptr) { - auto* b = reinterpret_cast<FetchIntoODBBackend*>(_backend); // NOLINT - return git_odb_write_pack( - _writepack, b->target_odb, progress_cb, progress_payload); - } - return GIT_ERROR; + Ensures(_backend != nullptr); + auto* b = reinterpret_cast<FetchIntoODBBackend*>(_backend); // NOLINT + return git_odb_write_pack( + _writepack, b->target_odb, progress_cb, progress_payload); } [[nodiscard]] auto fetch_backend_exists(git_odb_backend* _backend, const git_oid* oid) -> int { - if (_backend != nullptr) { - auto* b = reinterpret_cast<FetchIntoODBBackend*>(_backend); // NOLINT - return git_odb_exists(b->target_odb, oid); - } - return GIT_ERROR; + Ensures(_backend != nullptr); + auto* b = reinterpret_cast<FetchIntoODBBackend*>(_backend); // NOLINT + return git_odb_exists(b->target_odb, oid); } void fetch_backend_free(git_odb_backend* /*_backend*/) {} |