diff options
author | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-03-13 15:22:29 +0100 |
---|---|---|
committer | Paul Cristian Sarbu <paul.cristian.sarbu@huawei.com> | 2023-03-23 14:13:49 +0100 |
commit | ddb858a101e6da5d9e6f31c41777b7108e8952be (patch) | |
tree | 14a20e02db99dcb8121998446120cec31c823ccc /src | |
parent | f60a95ef44ebedfe6859577420fb89f0c24b9663 (diff) | |
download | justbuild-ddb858a101e6da5d9e6f31c41777b7108e8952be.tar.gz |
GitRepo: Add proper error message for repository initialisation
Diffstat (limited to 'src')
-rw-r--r-- | src/buildtool/file_system/git_repo.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/buildtool/file_system/git_repo.cpp b/src/buildtool/file_system/git_repo.cpp index 7fb0bc76..bf0b6ddc 100644 --- a/src/buildtool/file_system/git_repo.cpp +++ b/src/buildtool/file_system/git_repo.cpp @@ -364,6 +364,7 @@ auto GitRepo::InitAndOpen(std::filesystem::path const& repo_path, git_repository* tmp_repo{nullptr}; size_t max_attempts = 3; // number of tries int err = 0; + std::string err_mess{}; while (max_attempts > 0) { --max_attempts; err = git_repository_init( @@ -372,6 +373,7 @@ auto GitRepo::InitAndOpen(std::filesystem::path const& repo_path, git_repository_free(tmp_repo); return GitRepo(repo_path); // success } + err_mess = GitLastError(); // store last error message git_repository_free(tmp_repo); // cleanup before next attempt // check if init hasn't already happened in another process if (git_repository_open_ext(nullptr, @@ -383,11 +385,10 @@ auto GitRepo::InitAndOpen(std::filesystem::path const& repo_path, // repo still not created, so sleep and try again std::this_thread::sleep_for(std::chrono::milliseconds(kWaitTime)); } - Logger::Log( - LogLevel::Error, - "initializing git repository {} failed with error code:\n{}", - (repo_path / "").string(), - err); + Logger::Log(LogLevel::Error, + "initializing git repository {} failed with:\n{}", + (repo_path / "").string(), + err_mess); } catch (std::exception const& ex) { Logger::Log(LogLevel::Error, "initializing git repository {} failed with:\n{}", |