diff options
author | Eelco Dolstra <edolstra@gmail.com> | 2020-02-04 21:55:57 +0100 |
---|---|---|
committer | Eelco Dolstra <edolstra@gmail.com> | 2020-02-04 21:55:57 +0100 |
commit | e2213d77a22a1d3d5d17167eb2760352760405e8 (patch) | |
tree | 03bb6e263715850614e994eb98a425f6781adda5 /src/libstore | |
parent | fa467de0902ff9efa9b4b084a77e7f3752f7eac0 (diff) |
Set 'ref' properly for local trees
Diffstat (limited to 'src/libstore')
-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; |