Skip to content

chore(server): port upstream git, Windows and speed fixes (2026-10-08) - #263

Merged
TheDarkPhantom merged 5 commits into
mainfrom
chore/upstream-git-fixes-2026-10-08
Oct 9, 2026
Merged

TheDarkPhantom merged 5 commits into
mainfrom
chore/upstream-git-fixes-2026-10-08

Conversation

@TheDarkPhantom

@TheDarkPhantom TheDarkPhantom commented Oct 8, 2026 •

Copy link
Copy Markdown
Owner

The fork has not merged upstream since 2026-07-30. This PR hand-ports four upstream git fixes onto the fork's GitVcsDriverCore: index lock contention, Windows long paths, untracked-file CPU cost, and a worktree data-loss bug.

Ported

  • fix(server): status polling no longer locks the git index pingdotgg/t3code#14718 status polling no longer locks the git index. Every git subprocess gets GIT_OPTIONAL_LOCKS=0. Numstat now uses the diff-index -M / diff-files plumbing commands. Unborn HEAD detection also recognises diff-index's bad revision 'HEAD'.
  • fix(server): status refresh no longer pegs CPU in repos with thousands of untracked files pingdotgg/t3code#16771 (re-expressed) the review diff no longer pegs the CPU when a repo has thousands of untracked files. The fork's status refresh has no Changes totals, so upstream's literal fix has nothing to patch here. The fork's cost was in readUntrackedReviewDiffs, which spawned one git diff --no-index per untracked file: about 100ms each on Windows, and 5,001 files ran past a 60s timeout. Untracked files are now added as intent-to-add entries to an empty temporary index and diffed with a single git diff, the same technique upstream uses. Upstream's 5,000-file cap marks the untracked diff as truncated beyond that. The real index is never touched, and a test asserts this.
  • fix(server): worktree cleanup no longer deletes files hidden by showUntrackedFiles=no pingdotgg/t3code#15834 worktree removal no longer deletes files hidden by status.showUntrackedFiles=no. git worktree remove now runs with -c status.showUntrackedFiles=normal. Avi Code addition: the fork's WorktreeCleanup had the same hole, in a worse form. Its isDirty flag came from git status, which hides those files. The cleanup dialog pre-selects "clean" dead worktrees, and the health monitor auto-removes them by deleting the directory outright. isDirty now comes from a new hasWorktreeChanges driver op that runs git status --porcelain --untracked-files=normal.
  • Avi Code addition: WorktreeCleanup now fails closed. If the hasWorktreeChanges dirty check errors, the worktree is treated as dirty, so the health monitor never auto-removes it and the dialog does not pre-select it. Before, a failed check counted as clean. A test covers a failing check.
  • fix(server): Windows worktrees with long paths no longer fail or strand pingdotgg/t3code#14917 Windows worktrees with long paths no longer fail or get stranded. On win32, core.longpaths=true is appended to each git subprocess via GIT_CONFIG_COUNT/KEY/VALUE, keeping any inherited entries.

Skipped

Verification

  • vp test run (before the fail-closed commit) on GitVcsDriverCore, GitWorkflowService, WorktreeCleanup, WorktreeCleanupExecute, WorktreeHealthMonitor, ReviewService and VcsStatusBroadcaster tests: 101 passed, 1 failed. The failure is preserves newline characters in worktree paths when listing refs, which also fails on unmodified origin/main on Windows because Windows cannot create a path containing a newline.
  • With each fix reverted, its new test fails: the index bytes change; the uncapped untracked diff contains bulk/; the hidden worktree file gets deleted.
  • Fail-closed commit: WorktreeCleanup, WorktreeCleanupExecute and WorktreeHealthMonitor tests pass (29/29), and the new test fails with the old fail-open behaviour.
  • vp lint and vp fmt --check pass on the changed files. tsgo --noEmit -p apps/server/tsconfig.json reports no errors. vp run check:avicode and vp run test:avicode (7/7) pass.

🤖 Generated with Claude Code

TheDarkPhantom and others added 4 commits October 8, 2026 20:44
…14718)

Ports upstream 447046b. Git subprocesses run with GIT_OPTIONAL_LOCKS=0 so
`git status` stops taking index.lock to save a refreshed index, and the
working tree numstat uses plumbing `git diff-index -M` (and `diff-files` on an
unborn HEAD) because porcelain `git diff` rewrites the index regardless.
Unborn HEAD detection now also recognises diff-index's "bad revision 'HEAD'".

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…usands of untracked files (pingdotgg#16771)

Re-expresses upstream 10395bc for the fork. The fork's status refresh has
no Changes totals, but its review diff spawned one `git diff --no-index` per
untracked file (about 100ms each on Windows; 5,001 files ran past a minute).
Untracked files are now added as intent-to-add entries to an empty temporary
index and diffed in a single `git diff`, the same technique upstream uses, and
upstream's 5,000-file cap reports the untracked diff truncated beyond that.
The repository's real index is never touched.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…ntrackedFiles=no (pingdotgg#15834)

Ports upstream d9068d3. `git worktree remove` refuses to drop untracked
files unless forced, but its check honors `status.showUntrackedFiles=no`, so
it deleted them. Removal now runs with `-c status.showUntrackedFiles=normal`.

Avi Code addition: the fork's worktree cleanup had the same hole. Its dirty
flag came from `git status`, which hides those files, and the dialog
pre-selects and the health monitor auto-removes "clean" dead worktrees by
deleting the directory. The flag now comes from a new hasWorktreeChanges driver
op that runs `git status --porcelain --untracked-files=normal`.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…nd (pingdotgg#14917)

Ports upstream 4ce6a51. Git for Windows cannot create or delete paths past
MAX_PATH unless core.longpaths is set, so deep worktrees failed to check out
and failed midway through removal. On Windows every git subprocess now gets
core.longpaths=true appended through GIT_CONFIG_COUNT/KEY/VALUE, preserving
inherited entries and leaving argv and the user's config untouched.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. size:L labels Oct 8, 2026
Avi Code addition. When the cleanup dirty check failed, the worktree was
treated as clean, so the dialog pre-selected it and the health monitor could
auto-remove it. A failed check now reads as dirty.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
@TheDarkPhantom
TheDarkPhantom merged commit 86829d7 into main Oct 9, 2026
12 checks passed
@TheDarkPhantom
TheDarkPhantom deleted the chore/upstream-git-fixes-2026-10-08 branch October 9, 2026 01:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant