diff --git a/internal/p9/beads.go b/internal/p9/beads.go index bac329b..3f9f852 100644 --- a/internal/p9/beads.go +++ b/internal/p9/beads.go @@ -186,6 +186,21 @@ func (b *BeadsFS) Mount(name, cwd string) error { return fmt.Errorf("mount path must be exactly 1 level deep from project dirs (%v)", config.ProjectDirs) } } + // Reject if cwd is a git worktree (not the main repo) + gitPath := filepath.Join(cwd, ".git") + if info, err := os.Stat(gitPath); err == nil && !info.IsDir() { + return fmt.Errorf("mount path is a git worktree, not a base repo — mount the parent project instead") + } + // Reject if cwd contains git worktrees (feature workspace, not base workspace) + entries, _ := os.ReadDir(cwd) + for _, e := range entries { + if e.IsDir() { + subGit := filepath.Join(cwd, e.Name(), ".git") + if info, err := os.Stat(subGit); err == nil && !info.IsDir() { + return fmt.Errorf("mount path contains git worktrees — this is a feature workspace, mount the base workspace instead") + } + } + } // Warn if new mount overlaps with existing mounts for _, m := range b.mounts { if strings.HasPrefix(cwd, m.cwd+"/") { diff --git a/mcptools/mount_beads.sh b/mcptools/mount_beads.sh index ef47f7e..9dc0736 100755 --- a/mcptools/mount_beads.sh +++ b/mcptools/mount_beads.sh @@ -20,18 +20,6 @@ if [ -z "$CWD" ]; then exit 1 fi -# Reject if CWD is a git worktree (not the main repo) -if [ -f "$CWD/.git" ]; then - echo "error: $CWD is a git worktree, not a base repo — mount the parent project instead" >&2 - exit 1 -fi - -# Reject if CWD contains git worktrees (feature workspace, not base workspace) -if find "$CWD" -maxdepth 2 -name ".git" -type f 2>/dev/null | grep -q .; then - echo "error: $CWD contains git worktrees — this is a feature workspace, mount the base workspace instead" >&2 - exit 1 -fi - MOUNT=$(uuidgen | cut -d- -f1) echo "mount $CWD $MOUNT" | 9p write anvillm/beads/ctl