MCPcopy Create free account
hub / github.com/NixOS/nix / parseLsRemoteLine

Function parseLsRemoteLine

src/libutil/git.cc:341–352  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

339}
340
341std::optional<LsRemoteRefLine> parseLsRemoteLine(std::string_view line)
342{
343 const static std::regex line_regex("^(ref: *)?([^\\s]+)(?:\\t+(.*))?$");
344 std::match_results<std::string_view::const_iterator> match;
345 if (!std::regex_match(line.cbegin(), line.cend(), match, line_regex))
346 return std::nullopt;
347
348 return LsRemoteRefLine{
349 .kind = match[1].length() == 0 ? LsRemoteRefLine::Kind::Object : LsRemoteRefLine::Kind::Symbolic,
350 .target = match[2],
351 .reference = match[3].length() == 0 ? std::nullopt : std::optional<std::string>{match[3]}};
352}
353
354} // namespace nix::git

Callers 3

TESTFunction · 0.85
getRevFromRefMethod · 0.85
readHeadFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected