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
@kaii-zen
Copy link
Contributor

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

@edolstra edolstra added the feature Feature request or proposal label Jan 29, 2020
Copy link
Member Author

@Ma27 Ma27 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 flakes-fetchgit-worktree-support branch from e10dfd2 to c169ea5 Compare February 19, 2020 13:03
@Ma27
Copy link
Member Author

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 February 19, 2020 13:03
@edolstra edolstra merged commit 1d99c4a into NixOS:flakes Feb 19, 2020
@edolstra
Copy link
Member

Thanks!

@Ma27 Ma27 deleted the flakes-fetchgit-worktree-support branch February 19, 2020 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature Feature request or proposal flakes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants