diff options
-rw-r--r-- | src/libstore/fetchers/git.cc | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/src/libstore/fetchers/git.cc b/src/libstore/fetchers/git.cc index 1c74d92a4..35a5c18b5 100644 --- a/src/libstore/fetchers/git.cc +++ b/src/libstore/fetchers/git.cc @@ -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; |