From 8d9fd1818feee729e5adeab982608aff4eddd613 Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Mon, 13 Mar 2023 16:34:12 +0100 Subject: GitRepo: Make repository initialisation more robust As the initialisation of Git repositories is something that only takes place once, we should check early and cheaply whether the repository is already there before trying to initialize it. If we do need to initilize a repo, we can afford more attempts and longer wait times between tries to initalize if the failure to initialize happens due to the internal Git locking mechanism. --- src/buildtool/file_system/git_utils.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/buildtool/file_system/git_utils.hpp') diff --git a/src/buildtool/file_system/git_utils.hpp b/src/buildtool/file_system/git_utils.hpp index 68eb670b..5749c8b5 100644 --- a/src/buildtool/file_system/git_utils.hpp +++ b/src/buildtool/file_system/git_utils.hpp @@ -36,7 +36,10 @@ struct git_tree_entry; struct git_config; } -constexpr std::size_t kWaitTime{2}; // time in ms between tries for git locks +// time in ms between tries for git locks +constexpr std::size_t kGitLockWaitTime{100}; +// number of retries for git locks +constexpr std::size_t kGitLockNumTries{10}; [[nodiscard]] auto GitObjectID(std::string const& id, bool is_hex_id = false) noexcept -- cgit v1.2.3