Skip to content

fix(server): handle files named HEAD in git status - #6397

Open
Lucenx9 wants to merge 1 commit into
pingdotgg:mainfrom
Lucenx9:agent/fix-git-status-head-file
Open

fix(server): handle files named HEAD in git status#6397
Lucenx9 wants to merge 1 commit into
pingdotgg:mainfrom
Lucenx9:agent/fix-git-status-head-file

Conversation

@Lucenx9

@Lucenx9 Lucenx9 commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

What Changed

Disambiguate HEAD as a Git revision when collecting working-tree numstat data. The status path now terminates revision arguments with -- and preserves the existing fallback for repositories that do not have an initial commit yet.

A focused integration test creates and modifies a tracked file named HEAD, then verifies that GitVcsDriver.statusDetails() reports its line counts.

Why

git diff HEAD --numstat treats HEAD as ambiguous when the worktree also contains a file with that name, causing Git status collection to fail with exit code 128. The explicit revision/path boundary keeps valid repositories reportable without changing normal status behavior.

Validation

  • node_modules/.bin/vp test run apps/server/src/vcs/GitVcsDriverCore.test.ts — 48 passed
  • node_modules/.bin/vp run --filter t3 typecheck
  • Focused lint and format checks for both changed files

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • No UI changes
  • No motion or interaction changes

Implemented with OpenAI GPT-5.6 through the Codex harness in T3 Code.

Note

Fix git diff HEAD --numstat to handle files named HEAD in git status

  • Adds a pathspec separator -- to the git diff HEAD --numstat invocation in statusDetails, preventing Git from misinterpreting path tokens and allowing files literally named HEAD to appear in working tree changes.
  • Expands isUnbornHeadStderr in GitVcsDriverCore.ts to also match "bad revision 'head'" (case-insensitive), covering an additional Git error variant for unborn HEAD detection.

Macroscope summarized cdfbeee.


Note

Low Risk
Narrow VCS status fix with a regression test; normal repos are unchanged aside from the explicit -- on the diff invocation.

Overview
Fixes Git status collection when the worktree contains a tracked file named HEAD. statusDetails now runs git diff HEAD --numstat with a trailing -- so Git treats HEAD as the revision, not a pathspec.

isUnbornHeadStderr also recognizes bad revision 'head', so the existing unborn-HEAD numstat fallback still applies when appropriate.

An integration test commits a file named HEAD, modifies it, and asserts statusDetails reports the path and line counts.

Reviewed by Cursor Bugbot for commit cdfbeee. Bugbot is set up for automated code reviews on this repo. Configure here.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 8b1cda76-9a4e-4809-90a3-3b1b806799b4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added size:XS 0-9 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Aug 12, 2026
@Lucenx9
Lucenx9 marked this pull request as ready for review August 12, 2026 23:32
@macroscopeapp

macroscopeapp Bot commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Approved cdfbeee

Straightforward bug fix using standard git conventions. Adds -- separator to git diff commands to prevent files named 'HEAD' from being misinterpreted as the HEAD revision. Includes a test validating the fix.

You can customize Macroscope's approvability policy. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:XS 0-9 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant