Skip to content

Track delimiter-safe parsing for worktree paths with spaces or parentheses #493

@wfxr

Description

@wfxr

Check list

  • I have read through the README
  • I have the latest version of forgit
  • I have searched through the existing issues

Problem / Steps to reproduce

During review of #402, we noted that _forgit_extract_worktree_path() currently parses formatted worktree lines using cut -c6- | awk '{print $1}'.

This is not delimiter-safe and breaks for worktree paths that contain spaces or parentheses. As a result, worktree-related flows that depend on this parser can misbehave, including preview, yank, lock/unlock, delete, and jump/select operations.

This is being left as a TODO for now to keep #402 scoped and avoid making the parsing/display logic more complex in that PR.

A rough direction for a future fix would be to change the contract between _forgit_worktree_list() and _forgit_extract_worktree_path() so that the machine-readable path is emitted in a delimiter-safe form, for example by using a tab-delimited format and parsing it with cut -f1 or awk -F '\t'.

It would also be good to add regression tests that cover worktree paths containing spaces and parentheses.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions