Skip to content

fix(git): read diff blobs without revision path fallback - #34778

Merged
OrcaWin merged 1 commit into
mainfrom
OrcaWin/git-literal-blob-read
Oct 30, 2026
Merged

OrcaWin merged 1 commit into
mainfrom
OrcaWin/git-literal-blob-read

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​78 $\color{#cf222e}{\Huge{\mathbf{−}}}$​32 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​46
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​42 $\color{#cf222e}{\Huge{\mathbf{−}}}$​4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​38

Problem

For paths containing glob characters ([, *, ?), such as Next.js/SvelteKit routes like app/[id]/page.tsx or [...slug].tsx, the diff view of a new or added file showed the latest commit's header and message as the "original" side.

git show :<path> and git show --end-of-options HEAD:<path> fall back to pathspec mode when the blob does not exist. They exit 0 and print the HEAD commit, and Orca read that output as blob content with exists: true. This affected untracked diffs, staged additions, and commit/branch comparisons where one side is absent.

Fix

Index and tree blob reads now use git cat-file blob -- <spec>, which never falls back to a revision/path query. Normal-file bytes, binary/preview encoding, the 10 MiB TOO_LARGE_BLOB bound, and WSL read routing (cat-file is already classified read-only) are unchanged.

Older Git versions report only fatal: Not a valid object name <spec> for a missing path. Only in that exact case, a literal ls-files --stage -z / ls-tree -z probe runs. An empty successful listing proves absence. Corrupt objects, unknown refs, and failed probes are still reported as failed reads, not as absence.

Validation

  • New real-Git regression in blob-absence-real-git.test.ts: a bracket-named file in untracked, staged, and committed states gets an empty baseline from getDiff/getCommitDiff. It fails against the previous git show reader.
  • The absence matrix now runs through the readers themselves, using a plain name, a bracket name, and the quote/newline name.
  • pnpm test src/main/git plus the related runtime/provider diff tests pass (352 files).
  • pnpm check:changed --maxWorkers=2 passes (22/22).

…k to HEAD commit

git show :<path> and git show HEAD:<path> treat a missing blob spec as a
pathspec, exit 0, and print the HEAD commit when the path contains [, *
or ?. Orca then showed the commit header as the original side of new
files such as app/[id]/page.tsx. Read index and tree blobs with
git cat-file blob, and on older Git that only reports 'Not a valid
object name' prove absence with an empty literal ls-files/ls-tree probe.
@OrcaWin
OrcaWin force-pushed the OrcaWin/git-literal-blob-read branch from a7ea609 to 711bfb4 Compare October 30, 2026 08:36
@OrcaWin
OrcaWin marked this pull request as ready for review October 30, 2026 08:36
@OrcaWin
OrcaWin merged commit cb783ef into main Oct 30, 2026
70 of 71 checks passed
@OrcaWin
OrcaWin deleted the OrcaWin/git-literal-blob-read branch October 30, 2026 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant