mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 16:26:18 +02:00
Merge pull request #3229 from Ma27/flakes-fetchgit-worktree-support
builtins.fetchGit: Fix build when fetching a git worktree
This commit is contained in:
commit
1d99c4ab25
2 changed files with 18 additions and 1 deletions
|
@ -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) {
|
||||
|
|
|
@ -25,8 +25,16 @@ rev1=$(git -C $repo rev-parse HEAD)
|
|||
|
||||
echo world > $repo/hello
|
||||
git -C $repo commit -m 'Bla2' -a
|
||||
git -C $repo worktree add $TEST_ROOT/worktree
|
||||
echo hello >> $TEST_ROOT/worktree/hello
|
||||
rev2=$(git -C $repo rev-parse HEAD)
|
||||
|
||||
# Fetch a worktree
|
||||
unset _NIX_FORCE_HTTP
|
||||
path0=$(nix eval --impure --raw --expr "(builtins.fetchGit file://$TEST_ROOT/worktree).outPath")
|
||||
export _NIX_FORCE_HTTP=1
|
||||
[[ $(tail -n 1 $path0/hello) = "hello" ]]
|
||||
|
||||
# Fetch the default branch.
|
||||
path=$(nix eval --impure --raw --expr "(builtins.fetchGit file://$repo).outPath")
|
||||
[[ $(cat $path/hello) = world ]]
|
||||
|
|
Loading…
Reference in a new issue