aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2022-05-02 13:37:53 +0200
committerEelco Dolstra <edolstra@gmail.com>2022-05-02 13:37:53 +0200
commit61289ceee3417cd2aa8e8db9fe117a5813969aed (patch)
treebb4b7b5f43a31e6a6171f156d8465b6c36fa7a10
parent564faa6b4e568f5d1da2b92909aecd2c4eccc26c (diff)
Style fixes
-rw-r--r--src/libfetchers/git-utils.cc6
-rw-r--r--src/libfetchers/git.cc9
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 <regex>
-std::optional<std::string> parseListReferenceHeadRef(std::string_view line) {
+std::optional<std::string> parseListReferenceHeadRef(std::string_view line)
+{
const static std::regex head_ref_regex("^ref: ([^\\s]+)\\t+HEAD$");
std::match_results<std::string_view::const_iterator> match;
if (std::regex_match(line.cbegin(), line.cend(), match, head_ref_regex)) {
@@ -12,7 +13,8 @@ std::optional<std::string> parseListReferenceHeadRef(std::string_view line) {
}
}
-std::optional<std::string> parseListReferenceForRev(std::string_view rev, std::string_view line) {
+std::optional<std::string> parseListReferenceForRev(std::string_view rev, std::string_view line)
+{
const static std::regex rev_regex("^([^\\t]+)\\t+(.*)$");
std::match_results<std::string_view::const_iterator> 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;
}