about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorShea Levy <shea@shealevy.com>2017-12-27T23·50-0500
committerShea Levy <shea@shealevy.com>2017-12-27T23·50-0500
commit25196d0d26cf4ebe68099ebb28d287177425d307 (patch)
treebb6f598df94445abc38d4a03a1986a5e3ef7fb2b /src
parent4801420893766a3845f6ce6dc8c07bab1a2f15e0 (diff)
parent2e6f06c37e26a5ac5be35fe18f283a1b26de64bf (diff)
Merge branch 'fix/fetchGit-clean-branch' of git://github.com/dtzWill/nix
Diffstat (limited to 'src')
-rw-r--r--src/libexpr/primops/fetchGit.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/libexpr/primops/fetchGit.cc b/src/libexpr/primops/fetchGit.cc
index e92e0638031f..0d0b11958a4b 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;