wfxr / wfxr/forgit

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

Open
#493 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Shell
Stars
5.1k
Forks
166
Avg merge
1d 11h
Merged PRs (30d)
5

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with _forgit_worktree_list() and _forgit_extract_worktree_path(), then trace the preview, yank, lock/unlock, delete, and jump/select flows that consume the parsed path. Update the list-to-parser contract so paths remain delimiter-safe, add regression coverage for spaces and parentheses, and verify those worktree operations use the complete path.

Written by the indexing model from the issue text.

Assessment

Tech stack
git, shell
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.