pingdotgg / pingdotgg/t3code

[Bug]: Bare-root worktree layouts are silently accepted as a normal repo, making the project root the parent of every worktree

Open Beginner friendly
#8,164 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug needs-triage
Dominant language
TypeScript
Stars
23k
Forks
5.9k
Avg merge
11h 14m
Merged PRs (30d)
357

Description

Before submitting
  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.
Area

apps/server

Steps to reproduce

A common layout for worktree-heavy work puts a bare repo at <root>/.bare, a <root>/.git file pointing at it, and every branch as a sibling checkout — no primary working copy:

mkdir myproj && cd myproj
git clone --bare git@github.com:owner/repo.git .bare
echo "gitdir: ./.bare" > .git
git worktree add develop develop
git worktree add feature-x -b feature-x

Result:

myproj/
├── .bare/
├── .git          → gitdir: ./.bare
├── develop/
└── feature-x/
  1. Add myproj/ as a project in T3 Code.
  2. Open the Changes/Diff view, or start a thread.
Expected behavior

The root is rejected at add time with a message explaining that it is a bare-root layout and that an individual worktree should be added instead. Adding myproj/develop directly already works correctly today, so the fix is to stop accepting a root that cannot be a coherent workspace — not to add support for the layout itself.

Actual behavior

The root is accepted as an ordinary repository with no warning. detectRepository in apps/server/src/vcs/GitVcsDriver.ts gates on git rev-parse --is-inside-work-tree, and because the clone leaves core.bare=false, git reports:

$ git -C myproj rev-parse --is-inside-work-tree --show-toplevel --git-common-dir
true
/path/to/myproj
/path/to/myproj/.bare

So rootPath becomes myproj — the parent directory of every worktree. Downstream that means git status treats develop/ and feature-x/ as untracked entries, the diff/changes view is scoped to a directory that contains N independent checkouts, and any thread started there runs an agent whose cwd spans all of them. .bare/ itself is correctly rejected (--is-inside-work-tree is false), so the failure is specific to the root.

There is no bare-specific handling anywhere in the git layer — GitManager.ts mentions "bare" once, about branch names.

Impact

Minor bug or occasional failure

Version or commit

0.0.33 (macOS desktop)

Environment

macOS 26.5.2, git 2.50.1

Logs or stack traces

Screenshots, recordings, or supporting files

No response

Workaround

Add each worktree directory as its own project and never add the root.

detectRepository already calls git rev-parse --git-common-dir alongside --show-toplevel, so the detection needs no new git calls: a common dir that sits inside rootPath but is not rootPath/.git identifies this layout.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in apps/server/src/vcs/GitVcsDriver.ts and inspect detectRepository's existing rev-parse results, especially --show-toplevel and --git-common-dir. Reproduce the bare-root layout from the issue, reject the root while keeping an individual worktree accepted, and verify that adding the worktree directly still works.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, typescript
Domain
backend, devtools
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
76/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.