Skip to content

fix(git): preserve POSIX filenames in index blob reads - #35092

Closed
OrcaWin wants to merge 1 commit into
mainfrom
OrcaWin/git-index-path-identity
Closed

OrcaWin wants to merge 1 commit into
mainfrom
OrcaWin/git-index-path-identity

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​122 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​120
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​1 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1

Opening the unstaged diff for a POSIX file named odd\name.txt can read the index entry for the distinct file odd/name.txt. Staged additions can also appear empty when the rewritten path is absent. Preserve literal POSIX backslashes in index blob reads by converting only the executing host's path separator. Native Windows and Windows-host WSL keep their current separator conversion.

This changes one production line. Git commands, read limits, cache identity, IPC/RPC contracts and index contents remain unchanged.

Actual Git 2.25.5 and 2.55.0 reproduction Before After
Selected file's index content Neighbor's staged bytes Selected file's staged bytes
Unstaged diff baseline Neighbor's staged bytes Selected file's staged bytes
Staged diff modified side Neighbor's staged bytes Selected file's staged bytes
Slash-named neighbor and index bytes Preserved Preserved

Validation:

  • The two new real-Git regressions fail on the pinned baseline, including the unborn-branch staged addition.
  • Three focused suites / 25 tests pass with both Git versions. The standalone production-runner matrix separately verifies the actual executed Git version, local IPC path validation, both diff modes, neighbor contents and unchanged index bytes.
  • Simulated execution-host controls cover POSIX, native Windows and Windows-host WSL spellings. Independent source review approved the exact four-file scope.
  • Required pnpm check:changed --base=2d3e7e452000c26433650d75422e79a06be80684 --maxWorkers=2: 19/20 checks passed in 643.8 seconds. The broad affected unit selection was stopped after 641.6 seconds without an aggregate test result; verified process ancestry, cwd and start times before stopping its four owned processes. Formatting, lint/code-quality, typechecks and remaining ratchets passed. The aggregate gate is not green. An initial test-only type-import lint finding was corrected before this final run.
  • Native Windows/WSL, macOS, live SSH, full desktop builds and rendered UI were not run. Screenshots are N/A for this backend filename-identity fix. Ordinary repository directories exercise the folder-workspace case; the host's local Git provider also serves remote requests on that host's OS.

Integration and limits: #27757 fixes the runtime path validator and committed/OID blob reader; it leaves the index reader unchanged. This draft deliberately fixes that remaining index boundary. Until #27757 is integrated, runtime requests can still lose the filename before this reader and staged/HEAD comparisons can still use the wrong committed side; the standalone evidence retains those failing-side controls. #34778 separately fixes old-Git show revision/path fallback and missing-path classification: preserve its cat-file/targeted absence checks together with this host-separator conversion. #34767, #34967 and #35084 also touch the blob reader; retain their limits, incomplete-read handling and link classification during integration. Submodule path routing has separate normalization and is outside this scope.

@OrcaWin

OrcaWin commented Oct 30, 2026

Copy link
Copy Markdown
Collaborator Author

This only affects POSIX filenames containing a literal backslash, an exotic case. The change also covers only the index reader: readGitBlobAtOidPath still rewrites backslashes, so a staged diff would compare HEAD:odd/name.txt with :odd\name.txt. Runtime/mobile/remote paths are normalized upstream in runtime-relative-paths.ts, so they are not fixed either. If pursued, handle both readers together in #27757.

@OrcaWin OrcaWin closed this Oct 30, 2026
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