Skip to content

fix: getStatus consumes the second path of porcelain -z rename records - #572

Merged
chaitanyagiri merged 1 commit into
HarnessMD:mainfrom
TTAWDTT:fix/bug-11-integrations-security
Oct 2, 2026
Merged

chaitanyagiri merged 1 commit into
HarnessMD:mainfrom
TTAWDTT:fix/bug-11-integrations-security

Conversation

@TTAWDTT

@TTAWDTT TTAWDTT commented Sep 20, 2026

Copy link
Copy Markdown
Contributor

What & why

Git porcelain -z format encodes renames as two NUL-separated paths (old + new). The getStatus parser only consumed the first path, causing the second path to leak into subsequent entries and corrupt the status report. The fix consumes both paths for rename entries.

Type of change

  • Bug fix

Evidence

Before

before — tests fail on main

After

after — all tests pass on fix branch

How I tested it

  • OS: Windows 11 Pro (10.0.26200), Node v24.19.0
  • Steps:
    1. Ran node --test test/git-status-rename.test.cjs against unfixed main — regression tests fail (red).
    2. Same suite on this branch — all pass (green).
    3. npm run typecheck clean.

Credit (optional)

Discord: ttawdtt

X:

Checklist

  • Before and after evidence is attached above, under both headings.
  • npm run typecheck passes.
  • npm run test:focused passes (except pre-existing Windows-env failures unrelated to this change, identical on clean main).
  • npm run build succeeds.
  • This PR is one change. Unrelated fixes belong in their own PR.
  • I read the diff myself before opening this, and there is no debug output, commented-out code, or unrelated formatting churn in it.
  • Any new UI derives from DESIGN.md / tokens.ts — no ad-hoc colors, spacing, or fonts.
  • If I added art, it's my own or compatibly licensed, and listed in ATTRIBUTION.md.

Porcelain -z emits rename/copy records with two null-terminated paths
("R  <new>\0<old>\0"), but getStatus read every token as a single
"XY <path>" record, so the old path parsed as a phantom status entry
whose letters came from the filename ("alpha.txt" -> path "ha.txt",
index 'a', worktree 'l') and appeared in both the staged and unstaged
lists while the real old path was dropped; a 2-char old name was
silently skipped instead.

Parse it the way parseNameStatusZ already does: consume the source
token and keep it on the entry as oldPath (new optional field), so the
IDE panel's staged/unstaged lists no longer show files that do not
exist.
@chaitanyagiri
chaitanyagiri merged commit c342c32 into HarnessMD:main Oct 2, 2026
3 checks passed
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.

2 participants