Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

builtins.fetchGit: Fix build when fetching a git worktree #3229

Merged
merged 1 commit into from Feb 19, 2020

Conversation

@Ma27
Copy link
Member

@Ma27 Ma27 commented Nov 15, 2019

Worktrees[1] are a feature of git which allow you to check out a ref in
a different directory.

While playing around with flakes I realized that git repositories in a
worktree checkout break when trying to build a flake:

$ git worktree add ../nixpkgs-flakes nixpkgs-flakes
$ cd ../nixpkgs-flakes
$ nix build .#hello
error: opening directory '/home/ma27/Projects/nixpkgs-flakes/.git/refs/heads': Not a directory

This issue has been fixed by determining with git rev-parse --git-common-dir
where the actual .git directory is.

Please note that this issue only exists on the flakes branch, fetching
worktree checkouts with Nix master seems to work fine.

[1] https://git-scm.com/docs/git-worktree

@zimbatm zimbatm added the flakes label Nov 15, 2019
@kreisys
Copy link

@kreisys kreisys commented Dec 10, 2019

Just hit this too. I rely quite heavily on git worktrees in my flow.

@edolstra edolstra added the feature label Jan 29, 2020
Copy link
Member Author

@Ma27 Ma27 left a comment

This currently conflicts with recent changes on the flakes branch due to the introduction of several fetchers. I'm currently checking how to fix the issue with those changes.

Worktrees[1] are a feature of git which allow you to check out a ref in
a different directory.

While playing around with flakes I realized that git repositories in a
worktree checkout break when trying to build a flake:

```
$ git worktree add ../nixpkgs-flakes nixpkgs-flakes
$ cd ../nixpkgs-flakes
$ nix build .#hello
error: opening directory '/home/ma27/Projects/nixpkgs-flakes/.git/refs/heads': Not a directory
```

This issue has been fixed by determining with `git rev-parse --git-common-dir`
where the actual `.git` directory is.

Please note that this issue only exists on the `flakes` branch, fetching
worktree checkouts with Nix master seems to work fine.

[1] https://git-scm.com/docs/git-worktree
@Ma27 Ma27 force-pushed the Ma27:flakes-fetchgit-worktree-support branch from e10dfd2 to c169ea5 Feb 19, 2020
@Ma27
Copy link
Member Author

@Ma27 Ma27 commented Feb 19, 2020

Just rebased onto latest master and ensured that the issue is still fixed with this patch :)

@Ma27 Ma27 requested a review from edolstra Feb 19, 2020
@edolstra edolstra merged commit 1d99c4a into NixOS:flakes Feb 19, 2020
@edolstra
Copy link
Member

@edolstra edolstra commented Feb 19, 2020

Thanks!

@Ma27 Ma27 deleted the Ma27:flakes-fetchgit-worktree-support branch Feb 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

4 participants
You can’t perform that action at this time.