MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / gitFileNamesWorktree

Function gitFileNamesWorktree

src/extraction/index.ts:946–958  ·  view source on GitHub ↗

* 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)

Source from the content-addressed store, hash-verified

944 * folder is indexed, as before.
945 */
946function 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). */
961const LINKED_WORKTREE_RECHECK_MS = 1000;

Callers 3

classifyGitDirFunction · 0.85
isLinkedWorktreeMethod · 0.85
walkFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected