* Whether a `.git` FILE points at a worktree's gitdir (see classifyGitDir). * An unreadable pointer, or a `.git` that is no file, is no worktree: the * folder is indexed, as before.
(gitFile: string)
| 944 | * folder is indexed, as before. |
| 945 | */ |
| 946 | function gitFileNamesWorktree(gitFile: string): boolean { |
| 947 | try { |
| 948 | const gitdir = fs.readFileSync(gitFile, 'utf8').match(/^gitdir:\s*(.+)$/m)?.[1]?.trim(); |
| 949 | // A worktree's gitdir lives under some repo's `.git/worktrees/<name>` — |
| 950 | // either the top-level repo's (`.git/worktrees/`) or, for a worktree of a |
| 951 | // submodule, that submodule's gitdir (`.git/modules/<module>/worktrees/`). |
| 952 | // The optional `modules/<module>` segment covers the submodule case (#945). |
| 953 | // Match both separators so a Windows-style pointer is recognized too. |
| 954 | return !!gitdir && /(^|[\\/])\.git[\\/](modules[\\/][^\\/]+[\\/])?worktrees[\\/]/.test(gitdir); |
| 955 | } catch { |
| 956 | return false; |
| 957 | } |
| 958 | } |
| 959 | |
| 960 | /** How long, at most, a folder seen NOT to be a linked worktree is taken to stay so (LinkedWorktreeProbe). */ |
| 961 | const LINKED_WORKTREE_RECHECK_MS = 1000; |
no outgoing calls
no test coverage detected