Repository navigation
fix(nix): support git worktree checkouts - #427
boxcee-interview wants to merge 1 commit into
Conversation
Signed-off-by: Moritz Schmitz von Hülst <mschmitzvonhuelst@gmail.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
Closes #425
nix.shbind-mounts only$(pwd)at/crossplane-cli. In a git worktree checkout,.gitis a file pointing at the main clone's.git/worktrees/<name>— a path the container never sees. The container's first git command (git config --global --add safe.directory) therefore fails withfatal: not a git repository(exit 128) andset -eaborts the script before Nix starts.Following the fix suggested in the issue: when
.gitis a file (worktree), also bind-mount the main clone's git dir and the worktree itself at their host paths — that is what Nix (libgit2) resolves the worktree path from — and add both host paths tosafe.directoryinside the container. Regular-clone runs are unaffected (no extra mounts, no extra safe.directory entries).How to Test
Verified in a container reproducing the mount layout: with the common git dir and worktree mounted at their host paths and both added to
safe.directory,git status/git rev-parsesucceed in the worktree directory (exit 0); with the original single mount they fail exactly as reported (exit 128).