Skip to content

Commit c8b2264

Browse files
committed
readHead(): Make sure we're returning the HEAD ref line
If we previously fetched by revision, the output of "git ls-remote" won't start with the expected line like ref: refs/heads/master HEAD but will be something like 5c4410e3b9891c05ab40d723de78c6f0be45ad30 refs/heads/5c4410e3b9891c05ab40d723de78c6f0be45ad30 This then causes Nix to treat that revision as a refname, which then leads to warnings like warning: could not update cached head '5c4410e3b9891c05ab40d723de78c6f0be45ad30' for 'file:///tmp/repo'
1 parent ee9fa0d commit c8b2264

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/libfetchers/git.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ std::optional<std::string> readHead(const Path & path)
6969

7070
std::string_view line = output;
7171
line = line.substr(0, line.find("\n"));
72-
if (const auto parseResult = git::parseLsRemoteLine(line)) {
72+
if (const auto parseResult = git::parseLsRemoteLine(line); parseResult && parseResult->reference == "HEAD") {
7373
switch (parseResult->kind) {
7474
case git::LsRemoteRefLine::Kind::Symbolic:
7575
debug("resolved HEAD ref '%s' for repo '%s'", parseResult->target, path);

0 commit comments

Comments
 (0)