haskell.nix icon indicating copy to clipboard operation
haskell.nix copied to clipboard

`cleanGit` doesn't detect git worktrees correctly

Open typetetris opened this issue 4 years ago • 2 comments

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.

typetetris avatar Oct 20 '20 08:10 typetetris

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}";

nomeata avatar Nov 08 '20 08:11 nomeata

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.

stale[bot] avatar Sep 28 '22 21:09 stale[bot]