Style fixes

This commit is contained in:
Eelco Dolstra 2022-05-02 13:37:53 +02:00
parent 564faa6b4e
commit 61289ceee3
2 changed files with 7 additions and 8 deletions

View file

@ -2,7 +2,8 @@
#include <regex> #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$"); const static std::regex head_ref_regex("^ref: ([^\\s]+)\\t+HEAD$");
std::match_results<std::string_view::const_iterator> match; std::match_results<std::string_view::const_iterator> match;
if (std::regex_match(line.cbegin(), line.cend(), match, head_ref_regex)) { 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+(.*)$"); const static std::regex rev_regex("^([^\\t]+)\\t+(.*)$");
std::match_results<std::string_view::const_iterator> match; std::match_results<std::string_view::const_iterator> match;
if (!std::regex_match(line.cbegin(), line.cend(), match, rev_regex)) { if (!std::regex_match(line.cbegin(), line.cend(), match, rev_regex)) {

View file

@ -28,14 +28,11 @@ const std::string gitInitialBranch = "__nix_dummy_branch";
std::string getGitDir() std::string getGitDir()
{ {
auto gitDir = getEnv("GIT_DIR"); return getEnv("GIT_DIR").value_or(".git");
if (!gitDir) {
return ".git";
}
return *gitDir;
} }
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; return st.st_mtime + settings.tarballTtl > now;
} }