diff options
-rw-r--r-- | src/buildtool/file_system/TARGETS | 1 | ||||
-rw-r--r-- | src/buildtool/file_system/git_cas.cpp | 19 |
2 files changed, 17 insertions, 3 deletions
diff --git a/src/buildtool/file_system/TARGETS b/src/buildtool/file_system/TARGETS index 1af5dea8..26bb3933 100644 --- a/src/buildtool/file_system/TARGETS +++ b/src/buildtool/file_system/TARGETS @@ -57,6 +57,7 @@ , "private-deps": [ ["src/buildtool/logging", "logging"] , ["src/utils/cpp", "hex_string"] + , ["src/utils/cpp", "path"] , ["", "libgit2"] ] } diff --git a/src/buildtool/file_system/git_cas.cpp b/src/buildtool/file_system/git_cas.cpp index f134a894..7bddf6b3 100644 --- a/src/buildtool/file_system/git_cas.cpp +++ b/src/buildtool/file_system/git_cas.cpp @@ -21,6 +21,7 @@ #include "gsl/gsl" #include "src/buildtool/logging/logger.hpp" #include "src/utils/cpp/hex_string.hpp" +#include "src/utils/cpp/path.hpp" #ifndef BOOTSTRAP_BUILD_TOOL @@ -155,9 +156,21 @@ auto GitCAS::OpenODB(std::filesystem::path const& repo_path) noexcept -> bool { git_odb* odb_ptr{nullptr}; git_repository_odb(&odb_ptr, repo); odb_.reset(odb_ptr); // retain odb pointer - // set root - git_path_ = std::filesystem::weakly_canonical(std::filesystem::absolute( - std::filesystem::path(git_repository_path(repo)))); + // set root + std::filesystem::path git_path = + ToNormalPath(git_repository_path(repo)); + if (not git_path.is_absolute()) { + try { + git_path = std::filesystem::absolute(git_path); + } catch (std::exception const& e) { + Logger::Log(LogLevel::Error, + "Failed to obtain absolute path for {}: {}", + git_path.string(), + e.what()); + return false; + } + } + git_path_ = git_path; // release resources git_repository_free(repo); } |