Skip to content

fix(git): parse sparse and cquoted paths on the SSH relay - #18352

Closed
fettpl wants to merge 1 commit into
stablyai:mainfrom
fettpl:fix/shared-git-porcelain-parsers
Closed

fettpl wants to merge 1 commit into
stablyai:mainfrom
fettpl:fix/shared-git-porcelain-parsers

Conversation

@fettpl

@fettpl fettpl commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

ELI5

Local Git listing already knew when a worktree was a sparse checkout, and already decoded quoted conflict file names. The SSH relay used a copy of those parsers that skipped both, so sparse SSH worktrees looked full and conflict paths with spaces or non-ASCII names stayed quoted. There is now one shared parser for both.

What Changed

  • Moved parseWorktreeList to src/shared/git-worktree-list-parser.ts. Porcelain sparse sets optional isSparse; without the line the field is omitted (Git 2.25).
  • Moved parseUnmergedEntry to src/shared/git-unmerged-entry.ts. Paths go through decodeGitCQuotedPath. Missing-file probes use async access and treat only ENOENT/ENOTDIR as deleted (EACCES stays modified).
  • Desktop modules re-export the shared functions. Relay git-handler-utils.ts deletes the drifted copies and re-exports the same implementations.
  • git.listWorktrees on the relay returns parser output, so isSparse is on the JSON result when present.
  • Relay status now awaits the async unmerged parser.
  • Tests for sparse present/absent, C-quoted unmerged paths, and EACCES vs ENOENT/ENOTDIR.

Why

The relay copy of parseWorktreeList had no sparse branch, so SSH sparse checkouts were unmarked for space-analysis, sparse UI, and adoption guards. The relay unmerged parser skipped C-quoted decode and used existsSync with catch-modified, so quoted conflict paths and fs-probe errors diverged from local. Sharing the desktop parsers in electron-free src/shared removes that drift.

isSparse is an optional JSON field (remote-wire Rule 1). Older clients ignore it. Git hosts older than 2.28 omit the porcelain line, which is the correct absent field.

Linked Issue

Fixes #18280

Visual Proof

N/A — no visual or interaction change. Parser-only; SSH list/status JSON may now include optional isSparse and decoded conflict paths.

Testing

  • pnpm test src/main/git/worktree-list-porcelain.test.ts src/main/git/worktree-porcelain-parsing.test.ts
  • pnpm test src/relay/git-handler-utils.test.ts src/relay/git-handler-status-ops.test.ts src/relay/git-handler-worktree-list.test.ts
  • pnpm test src/shared/git-unmerged-entry.test.ts
  • pnpm tc:node
  • pnpm run check:code-quality:changed
  • rg "function parseWorktreeList" src — one implementation
  • rg "function parseUnmergedEntry" src — one implementation (desktop/relay re-export)

Platforms exercised by tests: macOS (this workspace). Path joins use path.join. Windows/Linux/SSH hosts run the same shared parser on the execution host.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Review

  • Cross-platform: parsers are host-local. Worktree paths and conflict paths use path.join on the OS that runs Git (native, WSL, or SSH). No hardcoded metaKey or POSIX-only separators.
  • SSH/remote: this is the SSH fix. git.listWorktrees forwards optional isSparse. Mixed-version clients ignore the unknown field (Rule 1). Loss of contact is unchanged; this is parse-only.
  • Security: no new IPC, no new git subcommands, no Electron import on the relay. Quoted-path decode is the existing shared C-quote decoder.
  • Performance: unmerged rows that need a missing-file probe now await access instead of sync existsSync. Same cost class as desktop; avoids a false deleted on EACCES.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

plans/README.md was not updated: this dispatch was instructed not to commit files under plans/.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

Share parseWorktreeList and parseUnmergedEntry in src/shared so SSH
cannot drift from local: porcelain sparse sets optional isSparse, and
unmerged paths go through decodeGitCQuotedPath with the desktop
ENOENT/ENOTDIR probe.

Fixes stablyai#18280
@coderabbitai

coderabbitai Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

Next included review available in 42 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Team

Run ID: 2e5d62be-4f61-46a7-86bd-fec3a66a6604

📥 Commits

Reviewing files that changed from the base of the PR and between 720c329 and c069ae1.

📒 Files selected for processing (12)
  • src/main/git/source-control/status-conflict-entries.ts
  • src/main/git/worktree-list-parser.ts
  • src/relay/git-handler-status-ops.test.ts
  • src/relay/git-handler-status-ops.ts
  • src/relay/git-handler-utils.test.ts
  • src/relay/git-handler-utils.ts
  • src/relay/git-handler-worktree-list.test.ts
  • src/relay/git-handler-worktree-list.ts
  • src/relay/git-handler-worktree-operations.ts
  • src/shared/git-unmerged-entry.test.ts
  • src/shared/git-unmerged-entry.ts
  • src/shared/git-worktree-list-parser.ts

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.

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes

  • Unified parseWorktreeList into src/shared/git-worktree-list-parser.ts — one shared parser now serves both desktop and relay, setting optional isSparse from the porcelain sparse line and omitting it when absent.
  • Unified parseUnmergedEntry into src/shared/git-unmerged-entry.ts — the shared parser C-quote-decodes conflict paths and probes the filesystem with async access, treating only ENOENT/ENOTDIR as deleted.
  • Desktop modules became one-line re-exports — worktree-list-parser.ts and status-conflict-entries.ts now forward to the shared implementations.
  • Relay drift removed — git-handler-utils.ts deletes its duplicated parsers and re-exports the shared functions, dropping the now-internal parseConflictKind export.
  • Relay call sites updated — git.listWorktrees returns parser output so isSparse rides on the JSON, and getStatusOp awaits the now-async unmerged parser.

The dedupe is faithful: the desktop parser moved verbatim and the only wire delta is the additive optional isSparse field (remote-wire Rule 1, ignored by older clients) plus the corrected C-quote decoding of conflict paths. readRelayWorktreeList's narrower RelayWorktreeInfo mapping still drops isSparse, but that path feeds worktree-remove / base-ref-refresh only — the public git.listWorktrees handler returns the full parser output, so the fix reaches the client worktree model via mergeWorktree. Tests use exact assertions that can fail, and the affected suites (39 + 15 tests) plus pnpm tc:node all pass.

Pullfrog  | View workflow run | Using DeepSeek Pro (free via Pullfrog for OSS) | 𝕏

@fettpl

fettpl commented Sep 3, 2026

Copy link
Copy Markdown
Contributor Author

Superseded by maintainer merge #18389 which closed #18280. Same porcelain-parser share.

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.

Share git porcelain parsers so SSH cannot drift from local

1 participant