diff options
author | Will Dietz <w@wdtz.org> | 2017-12-22 14:18:29 -0600 |
---|---|---|
committer | Will Dietz <w@wdtz.org> | 2017-12-22 15:29:52 -0600 |
commit | 2e6f06c37e26a5ac5be35fe18f283a1b26de64bf (patch) | |
tree | ac324b128560f6f1610076ab08b0a8325f6dad30 /src/libexpr | |
parent | aa43cbb7646e880f871df4280f8a1909520136f0 (diff) |
fetchGit: Fix handling of local repo when not using 'master' branch
Add tests checking this behavior.
Diffstat (limited to 'src/libexpr')
-rw-r--r-- | src/libexpr/primops/fetchGit.cc | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/libexpr/primops/fetchGit.cc b/src/libexpr/primops/fetchGit.cc index e92e06380..0d0b11958 100644 --- a/src/libexpr/primops/fetchGit.cc +++ b/src/libexpr/primops/fetchGit.cc @@ -23,7 +23,7 @@ struct GitInfo }; GitInfo exportGit(ref<Store> store, const std::string & uri, - std::experimental::optional<std::string> ref, const std::string & rev, + std::experimental::optional<std::string> ref, std::string rev, const std::string & name) { if (!ref && rev == "" && hasPrefix(uri, "/") && pathExists(uri + "/.git")) { @@ -68,6 +68,10 @@ GitInfo exportGit(ref<Store> store, const std::string & uri, return gitInfo; } + + // clean working tree, but no ref or rev specified. Use 'HEAD'. + rev = chomp(runProgram("git", true, { "-C", uri, "rev-parse", "HEAD" })); + ref = "HEAD"s; } if (!ref) ref = "master"s; |