From 61289ceee3417cd2aa8e8db9fe117a5813969aed Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Mon, 2 May 2022 13:37:53 +0200 Subject: [PATCH] Style fixes --- src/libfetchers/git-utils.cc | 6 ++++-- src/libfetchers/git.cc | 9 +++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/src/libfetchers/git-utils.cc b/src/libfetchers/git-utils.cc index 060077098..b2d6b7893 100644 --- a/src/libfetchers/git-utils.cc +++ b/src/libfetchers/git-utils.cc @@ -2,7 +2,8 @@ #include -std::optional parseListReferenceHeadRef(std::string_view line) { +std::optional parseListReferenceHeadRef(std::string_view line) +{ const static std::regex head_ref_regex("^ref: ([^\\s]+)\\t+HEAD$"); std::match_results match; if (std::regex_match(line.cbegin(), line.cend(), match, head_ref_regex)) { @@ -12,7 +13,8 @@ std::optional parseListReferenceHeadRef(std::string_view line) { } } -std::optional parseListReferenceForRev(std::string_view rev, std::string_view line) { +std::optional parseListReferenceForRev(std::string_view rev, std::string_view line) +{ const static std::regex rev_regex("^([^\\t]+)\\t+(.*)$"); std::match_results match; if (!std::regex_match(line.cbegin(), line.cend(), match, rev_regex)) { diff --git a/src/libfetchers/git.cc b/src/libfetchers/git.cc index 2b81900fa..266246fe9 100644 --- a/src/libfetchers/git.cc +++ b/src/libfetchers/git.cc @@ -28,14 +28,11 @@ const std::string gitInitialBranch = "__nix_dummy_branch"; std::string getGitDir() { - auto gitDir = getEnv("GIT_DIR"); - if (!gitDir) { - return ".git"; - } - return *gitDir; + return getEnv("GIT_DIR").value_or(".git"); } -bool isCacheFileWithinTtl(const time_t now, const struct stat& st) { +bool isCacheFileWithinTtl(const time_t now, const struct stat & st) +{ return st.st_mtime + settings.tarballTtl > now; }