Skip to content

fix: use cygpath -ma on Windows so cmux ls path filter matches#23

Open
jeremylasne92-hue wants to merge 1 commit into
craigsc:mainfrom
jeremylasne92-hue:fix-windows-msys-path-compat
Open

fix: use cygpath -ma on Windows so cmux ls path filter matches#23
jeremylasne92-hue wants to merge 1 commit into
craigsc:mainfrom
jeremylasne92-hue:fix-windows-msys-path-compat

Conversation

@jeremylasne92-hue
Copy link
Copy Markdown

Fixes #22

Problem

On Windows (Git Bash / MSYS), cmux ls and cmux rm --all silently return empty because the path filter never matches:

  • realpath on MSYS returns POSIX form: /c/Users/foo/repo
  • git worktree list emits mixed form: C:/Users/foo/repo
  • grep -F "$filter" comparing these two strings yields zero matches

Fix

Introduce _cmux_canonical_path helper that prefers cygpath -ma (absolute + mixed format) when available, falling back to realpath everywhere else. _cmux_repo_root delegates to this helper.

  • Linux/macOS behavior: unchanged (no cygpath on PATH → realpath branch runs)
  • Windows behavior: path now matches git worktree list output format

Verification

On Windows Git Bash (MSYS2/MINGW64, bash 5.2.37, git 2.52.0.windows.1):

$ cd /c/Users/foo/repo
$ cmux new test-branch
# ...worktree created successfully
$ cmux ls
C:/Users/foo/repo/.worktrees/test-branch   hash [test-branch]  [ahead 1]
$ cmux rm test-branch -f
Deleted branch test-branch.
Removed worktree and branch: test-branch
$ cmux ls
# (empty, as expected)

Before the fix: cmux ls always empty. After the fix: worktrees are listed correctly.

Linux path (unchanged): running the same code in a non-MSYS environment takes the realpath branch since cygpath is not available.

Scope

Minimal one-function change (cmux.sh, +15 / -2). No new dependencies, no test additions (repo has no test suite per CLAUDE.md).

On Windows (Git Bash / MSYS), `realpath` returns POSIX form
(/c/Users/...) while `git worktree list` emits mixed form
(C:/Users/...). The grep-based filter in `_cmux_ls` (and derived
commands like `cmux rm --all`) therefore never matches any worktree,
producing an empty listing even when worktrees exist.

Fix: introduce `_cmux_canonical_path` that uses `cygpath -ma`
(absolute + mixed format) when available, falling back to `realpath`
on Linux/macOS. `_cmux_repo_root` now delegates to this helper.

Verified on Windows Git Bash (MSYS, bash 5.2, git 2.52): `cmux new`,
`cmux ls`, `cmux rm <branch>` all behave correctly post-fix. Linux
behavior is unchanged (cygpath is not present, realpath path runs).
@siennathesane
Copy link
Copy Markdown
Collaborator

On principal I'm onboard with this, thanks!

I don't want to place an extra burden on you but without a Windows machine (@craigsc & I both use macOS) I can't test this and I'm not sure we'll be able to support it.

Would it be a fair ask for you to add a Windows GitHub Actions runner config to this so we can make sure it stays supported and working properly? I don't want to break stuff for you later on and we need to be able to maintain it. I do think Windows support should be limited to Cygwin & WSL tho.

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.

[Bug] cmux ls returns empty on Windows Git Bash due to realpath/git-worktree path format mismatch

2 participants