aboutsummaryrefslogtreecommitdiff
path: root/src/libstore
diff options
context:
space:
mode:
authorEelco Dolstra <edolstra@gmail.com>2020-02-19 14:11:18 +0100
committerGitHub <noreply@github.com>2020-02-19 14:11:18 +0100
commit1d99c4ab25cfedd3d634c447035584d9c390d0e9 (patch)
treef7ae812e8288e88231fad7e5cdad31856ed90731 /src/libstore
parentf3505a78991458e8cc447d9bde0be5ff1aa39335 (diff)
parentc169ea59049f861aaba429f48b828d0820b74d1d (diff)
Merge pull request #3229 from Ma27/flakes-fetchgit-worktree-support
builtins.fetchGit: Fix build when fetching a git worktree
Diffstat (limited to 'src/libstore')
-rw-r--r--src/libstore/fetchers/git.cc11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/libstore/fetchers/git.cc b/src/libstore/fetchers/git.cc
index 134d44ecd..9276b0993 100644
--- a/src/libstore/fetchers/git.cc
+++ b/src/libstore/fetchers/git.cc
@@ -217,7 +217,16 @@ struct GitInput : Input
/* Check whether this repo has any commits. There are
probably better ways to do this. */
- bool haveCommits = !readDirectory(actualUrl + "/.git/refs/heads").empty();
+ auto gitDir = actualUrl + "/.git";
+ auto commonGitDir = chomp(runProgram(
+ "git",
+ true,
+ { "-C", actualUrl, "rev-parse", "--git-common-dir" }
+ ));
+ if (commonGitDir != ".git")
+ gitDir = commonGitDir;
+
+ bool haveCommits = !readDirectory(gitDir + "/refs/heads").empty();
try {
if (haveCommits) {