Set 'ref' properly for local trees

This commit is contained in:
Eelco Dolstra 2020-02-04 21:55:57 +01:00
parent fa467de090
commit e2213d77a2

View file

@ -23,6 +23,11 @@ static Path getCacheInfoPathFor(const std::string & name, const Hash & rev)
return cacheDir + "/" + linkName + ".link";
}
static std::string readHead(const Path & path)
{
return chomp(runProgram("git", true, { "-C", path, "rev-parse", "--abbrev-ref", "HEAD" }));
}
static void cacheGitInfo(
Store & store,
const std::string & name,
@ -268,7 +273,7 @@ struct GitInput : Input
}
}
if (!input->ref) input->ref = isLocal ? "HEAD" : "master";
if (!input->ref) input->ref = isLocal ? readHead(actualUrl) : "master";
Path repoDir;