diff options
Diffstat (limited to 'src/other_tools/git_operations')
-rw-r--r-- | src/other_tools/git_operations/TARGETS | 1 | ||||
-rw-r--r-- | src/other_tools/git_operations/git_repo_remote.cpp | 9 | ||||
-rw-r--r-- | src/other_tools/git_operations/git_repo_remote.hpp | 8 |
3 files changed, 18 insertions, 0 deletions
diff --git a/src/other_tools/git_operations/TARGETS b/src/other_tools/git_operations/TARGETS index 28e514f0..7f5dede1 100644 --- a/src/other_tools/git_operations/TARGETS +++ b/src/other_tools/git_operations/TARGETS @@ -29,6 +29,7 @@ , "stage": ["src", "other_tools", "git_operations"] , "private-deps": [ ["src/buildtool/logging", "logging"] + , ["src/buildtool/file_system", "git_utils"] , ["@", "fmt", "", "fmt"] , ["", "libgit2"] ] diff --git a/src/other_tools/git_operations/git_repo_remote.cpp b/src/other_tools/git_operations/git_repo_remote.cpp index 177a4301..7d2ee7f4 100644 --- a/src/other_tools/git_operations/git_repo_remote.cpp +++ b/src/other_tools/git_operations/git_repo_remote.cpp @@ -15,6 +15,7 @@ #include <src/other_tools/git_operations/git_repo_remote.hpp> #include "fmt/core.h" +#include "src/buildtool/file_system/git_utils.hpp" #include "src/buildtool/logging/logger.hpp" extern "C" { @@ -403,3 +404,11 @@ auto GitRepoRemote::FetchViaTmpRepo(std::filesystem::path const& tmp_repo_path, return false; } } + +auto GitRepoRemote::GetConfigSnapshot() const -> std::shared_ptr<git_config> { + git_config* cfg_ptr{nullptr}; + if (git_repository_config_snapshot(&cfg_ptr, GetRepoRef().get()) != 0) { + return nullptr; + } + return std::shared_ptr<git_config>(cfg_ptr, config_closer); +} diff --git a/src/other_tools/git_operations/git_repo_remote.hpp b/src/other_tools/git_operations/git_repo_remote.hpp index 83099994..334f7fca 100644 --- a/src/other_tools/git_operations/git_repo_remote.hpp +++ b/src/other_tools/git_operations/git_repo_remote.hpp @@ -17,6 +17,10 @@ #include "src/buildtool/file_system/git_repo.hpp" +extern "C" { +struct git_config; +} + /// \brief Extension to a Git repository, allowing remote Git operations. class GitRepoRemote : public GitRepo { public: @@ -93,6 +97,10 @@ class GitRepoRemote : public GitRepo { std::optional<std::string> const& branch, anon_logger_ptr const& logger) noexcept -> bool; + /// \brief Get a snapshot of the repository configuration. + /// Returns nullptr on errors. + [[nodiscard]] auto GetConfigSnapshot() const -> std::shared_ptr<git_config>; + private: /// \brief Open "fake" repository wrapper for existing CAS. explicit GitRepoRemote(GitCASPtr git_cas) noexcept; |