fix(worktrees): list a folder once when git reports it twice (#24357)

When git lists the same folder twice (a leftover worktree registration that points at the main checkout), Orca's runtime listing turned each line into its own worktree with the same id, so `orca worktree current`, `active` and `branch:` failed with selector_ambiguous, and paired clients saw a duplicate row. The runtime scan now keeps git's first row per folder, the rule the desktop sidebar already uses. Separately, for a bare or separate-git-dir repo added through a linked worktree, the scan no longer relabels the main row with that worktree's folder (it relabels only when the folder's git dir is the common git dir), so the worktree keeps its own row and branch in the CLI and the sidebar. No extra git command runs.

Part of #23631: the "Profile state writer command timed out" toast in that issue has a separate cause.
This commit is contained in:
Kelvin Amoaba
2026-10-02 17:33:00 -07:00
committed by GitHub
parent 56427f134a
commit de77c4b065
11 changed files with 323 additions and 33 deletions
+3 -2
View File
@@ -164,11 +164,12 @@ describeBinaryCompatibility('real Git binary compatibility', () => {
'rev-parse',
'--path-format=absolute',
'--show-toplevel',
'--git-common-dir'
'--git-common-dir',
'--git-dir'
])
expect(hasUnsupportedRevParsePathFormatEcho(preferred.stdout)).toBe(!supports(2, 31))
await expect(
runGit(['rev-parse', '--show-toplevel', '--git-common-dir'])
runGit(['rev-parse', '--show-toplevel', '--git-common-dir', '--git-dir'])
).resolves.toBeDefined()
})