haskell.nix
haskell.nix copied to clipboard
`cleanGit` doesn't detect git worktrees correctly
Take any repository using haskell.nix and cleanGit
and add a new worktree like
git worktree add ../new-worktree <commitish>
cd ../new-worktree
nix-shell # or whatever you do to trigger `shellFor` or so
and you should see
trace: gitSource.nix: /<path-to/new-worktree does not seem to be a git repository
but git ls-files
and the like would work.
The latest version of gitSource.nix
that I am using here internally has this logic to handle worktrees:
git_dir =
if builtins.pathExists ../.git/index
then ../.git
else # likely a git worktree, so follow the indirection
let
git_content = lines (readFile ./../.git);
first_line = head git_content;
prefix = "gitdir: ";
ok = length git_content == 1 && has_prefix prefix first_line;
in
if ok
then /. + remove_prefix prefix first_line
else abort "gitSource.nix: Cannot parse ${toString ./../.git}";
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.