#include "git.hh" #include namespace nix { namespace git { std::optional parseLsRemoteLine(std::string_view line) { const static std::regex line_regex("^(ref: *)?([^\\s]+)(?:\\t+(.*))?$"); std::match_results match; if (!std::regex_match(line.cbegin(), line.cend(), match, line_regex)) return std::nullopt; return LsRemoteRefLine { .kind = match[1].length() == 0 ? LsRemoteRefLine::Kind::Object : LsRemoteRefLine::Kind::Symbolic, .target = match[2], .reference = match[3].length() == 0 ? std::nullopt : std::optional{ match[3] } }; } } }