@gitkraken/core-gitlens 0.61.1 → 0.63.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -1
- package/dist/git/cache.d.ts +1 -0
- package/dist/git/cache.js +11 -0
- package/dist/git/cache.js.map +1 -1
- package/dist/git/errors.d.ts +15 -0
- package/dist/git/errors.js +9 -1
- package/dist/git/errors.js.map +1 -1
- package/dist/git/models/pullRequest.d.ts +3 -0
- package/dist/git/models/pullRequest.js.map +1 -1
- package/dist/git/providers/operations.d.ts +4 -3
- package/dist/git/providers/staging.d.ts +16 -8
- package/dist/git/run.types.d.ts +6 -0
- package/dist/git/service.js +6 -0
- package/dist/git/service.js.map +1 -1
- package/dist/git/utils/hiddenRefs.utils.d.ts +15 -0
- package/dist/git/utils/hiddenRefs.utils.js +68 -2
- package/dist/git/utils/hiddenRefs.utils.js.map +1 -1
- package/dist/git/utils/pullRequest.utils.d.ts +3 -6
- package/dist/git/utils/pullRequest.utils.js +6 -7
- package/dist/git/utils/pullRequest.utils.js.map +1 -1
- package/dist/git/watching/gitIgnoreFilter.d.ts +12 -5
- package/dist/git/watching/gitIgnoreFilter.js +26 -32
- package/dist/git/watching/gitIgnoreFilter.js.map +1 -1
- package/dist/git/watching/provider.d.ts +18 -3
- package/dist/git/watching/watchGroup.d.ts +7 -2
- package/dist/git/watching/watchGroup.js +51 -3
- package/dist/git/watching/watchGroup.js.map +1 -1
- package/dist/git/watching/watchService.d.ts +16 -2
- package/dist/git/watching/watchService.js +210 -88
- package/dist/git/watching/watchService.js.map +1 -1
- package/dist/git/watching/watcherPatterns.d.ts +1 -1
- package/dist/git/watching/watcherPatterns.js +11 -5
- package/dist/git/watching/watcherPatterns.js.map +1 -1
- package/dist/git-cli/cliGitProvider.d.ts +3 -6
- package/dist/git-cli/cliGitProvider.js +144 -38
- package/dist/git-cli/cliGitProvider.js.map +1 -1
- package/dist/git-cli/exec/git.js +4 -4
- package/dist/git-cli/exec/git.js.map +1 -1
- package/dist/git-cli/exec/indexLock.d.ts +7 -5
- package/dist/git-cli/exec/indexLock.js +19 -15
- package/dist/git-cli/exec/indexLock.js.map +1 -1
- package/dist/git-cli/providers/config.d.ts +1 -0
- package/dist/git-cli/providers/config.js +15 -5
- package/dist/git-cli/providers/config.js.map +1 -1
- package/dist/git-cli/providers/pausedOperations.js +2 -2
- package/dist/git-cli/providers/pausedOperations.js.map +1 -1
- package/dist/git-cli/providers/staging.d.ts +8 -8
- package/dist/git-cli/providers/staging.js +120 -25
- package/dist/git-cli/providers/staging.js.map +1 -1
- package/dist/ipc/discovery.js +1 -1
- package/dist/plus/agents/providers/claudeCodeTranscript.js +6 -6
- package/dist/plus/agents/providers/claudeCodeTranscript.js.map +1 -1
- package/dist/plus/ai/providers/openAICompatibleProviderBase.js +1 -1
- package/dist/plus/git-github/api/config.d.ts +5 -0
- package/dist/plus/git-github/api/config.js.map +1 -1
- package/dist/plus/git-github/api/github.js +24 -4
- package/dist/plus/git-github/api/github.js.map +1 -1
- package/dist/plus/git-github/models.d.ts +12 -0
- package/dist/plus/git-github/models.js +8 -3
- package/dist/plus/git-github/models.js.map +1 -1
- package/dist/plus/integrations/context.d.ts +5 -0
- package/dist/plus/integrations/providers/azure/azure.js +1 -1
- package/dist/plus/integrations/providers/github.js +7 -3
- package/dist/plus/integrations/providers/github.js.map +1 -1
- package/dist/plus/integrations/reads/etag.d.ts +5 -0
- package/dist/plus/integrations/reads/etag.js +2 -0
- package/dist/plus/integrations/reads/etag.js.map +1 -1
- package/dist/utils/env/node/exec.d.ts +2 -0
- package/dist/utils/env/node/exec.js +4 -2
- package/dist/utils/env/node/exec.js.map +1 -1
- package/docs/integrations.md +9 -9
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watchService.js","names":[],"sources":["../../../../git/src/watching/watchService.ts"],"sourcesContent":["import type { UnifiedDisposable } from '@gitlens/utils/disposable.js';\nimport type { Event } from '@gitlens/utils/event.js';\nimport { Emitter } from '@gitlens/utils/event.js';\nimport { isDescendant, relative } from '@gitlens/utils/path.js';\nimport type { ResourceUsage } from '@gitlens/utils/resourceUsage.js';\nimport { getRepositoryKey } from '@gitlens/utils/uri.js';\nimport type { GitDir, RepositoryChange } from '../models/repository.js';\nimport type { WatcherRepoChangeEvent } from './changeEvent.js';\nimport type { PollTarget } from './gitDirPoller.js';\nimport { GitDirPoller } from './gitDirPoller.js';\nimport type { GitIgnoreFilter } from './gitIgnoreFilter.js';\nimport type {\n\tFileWatcher,\n\tFileWatcherOptions,\n\tFileWatcherReliability,\n\tFileWatchEvent,\n\tFileWatchingProvider,\n\tGitIgnoreRefreshReason,\n\tGitIgnoreWatchInputs,\n\tGitIgnoringFileWatcher,\n} from './provider.js';\nimport { createWorkingTreeNoiseFilter, workingTreeExcludes } from './watcherPatterns.js';\nimport type { WatchGroupHooks } from './watchGroup.js';\nimport { WatchGroup } from './watchGroup.js';\nimport { RepositoryWatchSession } from './watchSession.js';\n\n/**\n * Cap on paths held while the gitignore filter loads. Higher than the session's own cap because these are\n * pre-filter — most of a build's output is typically gitignored and would be discarded on replay, so a\n * tighter bound here would mark batches incomplete when they filter down to almost nothing.\n */\nconst maxBufferedWorkingTreePaths = 5000;\n\nconst ignorePruningRefreshDelayMs = 500;\n\ninterface GitIgnoreDelegation {\n\treadonly watcher: GitIgnoringFileWatcher;\n\tinitialApplied: boolean;\n\trefreshing: boolean;\n\tverified: boolean;\n\tpendingRefresh?: Exclude<GitIgnoreRefreshReason, 'initial'>;\n}\n\ninterface CreatedWorkingTreeWatcher {\n\treadonly watcher: FileWatcher;\n\treadonly reliability: FileWatcherReliability;\n\treadonly awaitingStartAck: boolean;\n\treadonly delegation?: GitIgnoreDelegation;\n}\n\ninterface WorkingTreeWatcherEntry {\n\treadonly session: RepositoryWatchSession;\n\t/** The event handler shared by every watcher this entry has had — a re-created watcher reuses it */\n\treadonly onEvent: (event: FileWatchEvent) => void;\n\treadonly filter?: GitIgnoreFilter;\n\twatcher: FileWatcher | undefined;\n\tdelegation?: GitIgnoreDelegation;\n\t/** The git-ignored directories the live watcher was created excluding (on top of the static set) */\n\tignoredDirectories: readonly string[];\n\t/** Bumped by every ignore-rule change and by stopping; a read that lands under a different value is stale */\n\tgeneration: number;\n\treading: boolean;\n\t/** A refresh came due while a read was in flight */\n\trereadQueued: boolean;\n\trefreshTimer?: ReturnType<typeof setTimeout>;\n\t/** What the live watcher last reported; a re-created watcher starts over from its own report */\n\treliability: FileWatcherReliability;\n\tstarting: boolean;\n\tawaitingStartAck: boolean;\n\t/** Compares the host's working-tree fingerprint while the watcher isn't `reliable` */\n\tpollTarget?: PollTarget;\n\t/**\n\t * Git-ignored directories (repo-relative) whose events reached the post-filter, so the watcher isn't pruning them —\n\t * typically created after the last read (a first build's `dist/`). Each waits for a read that started after it.\n\t */\n\tunpruned?: Set<string>;\n\t/**\n\t * Directories a read showed git won't prune (they hold tracked files, or glob metacharacters in their names);\n\t * cleared when ignore rules change\n\t */\n\tunprunable?: Set<string>;\n}\n\n/**\n * A host whose watchers can report they can't be trusted (see `FileWatcherOptions.onDidChangeReliability`) passes\n * these to have core poll in their place. A `.git` directory is polled by statting the files its watchers read and\n * feeding each one that moved through the same interpretation as a watcher event; a working tree is never walked.\n */\nexport interface WatchPollingOptions {\n\t/**\n\t * Reads a path's modification time (ms) and size; `undefined` when it doesn't exist. A rejection means unknown:\n\t * the last reading stands, so it never counts as a change.\n\t */\n\treadonly stat: (path: string) => Promise<{ readonly mtime: number; readonly size: number } | undefined>;\n\t/** Whether a poll is worth running now. Default: the service isn't suspended (`suspendAll`/`resumeAll`) */\n\treadonly isActive?: () => boolean;\n\t/** How often each untrusted watcher is polled. Default: 60000ms */\n\treadonly intervalMs?: number;\n\t/**\n\t * How often `isActive` is looked at, which bounds how late the first poll after it turns true can be. Only with\n\t * `isActive`: the default gate wakes only for a poll. Default: 5000ms\n\t */\n\treadonly activeCheckMs?: number;\n\t/**\n\t * Refs to poll for a repository beyond its subscribers' `relevantRefs`: one with none (a host listing every branch)\n\t * still needs its checked-out branch's upstream, which a push moves without writing `FETCH_HEAD`\n\t */\n\treadonly getRefs?: (repoPath: string) => Iterable<string>;\n\t/**\n\t * Something that changes whenever the repository's working tree does (e.g. a digest of its status and the\n\t * changed files' stats), compared at each poll while working-tree subscribers are watching a working tree whose\n\t * watcher can't be trusted; a change is reported with no paths. `undefined` or a rejection skips that poll. With or\n\t * without it, a working tree whose watcher is `unwatchable` is reported changed (no paths) whenever its index or\n\t * `HEAD` changes.\n\t */\n\treadonly getWorkingTreeFingerprint?: (repoPath: string) => Promise<string | undefined>;\n}\n\nexport interface WatchServiceOptions {\n\treadonly watchingProvider: FileWatchingProvider;\n\t/** Default debounce for repo changes when subscriber doesn't specify. Default: 250ms */\n\treadonly defaultRepoDelayMs?: number;\n\t/** Default debounce for working tree changes when subscriber doesn't specify. Default: 2500ms */\n\treadonly defaultWorkingTreeDelayMs?: number;\n\t/** Default cap on how long continuous repo activity can defer a flush. `Infinity` disables it. Default: 2000ms */\n\treadonly defaultRepoMaxWaitMs?: number;\n\t/** Default cap on how long continuous working tree activity can defer a flush. `Infinity` disables it. Default: 10000ms */\n\treadonly defaultWorkingTreeMaxWaitMs?: number;\n\t/** Returns a GitIgnoreFilter for a given repo. When absent or returns undefined, gitignore filtering is skipped. */\n\treadonly getIgnoreFilter?: (repoPath: string, gitDirPath: string) => GitIgnoreFilter | undefined;\n\t/**\n\t * Returns repo-relative ignored directories for legacy native exclude pruning (`supportsExcludes`).\n\t * A rejection keeps the existing excludes.\n\t */\n\treadonly getIgnoredDirectories?: (repoPath: string) => Promise<readonly string[]>;\n\t/** Inputs for a provider-managed watch. Undefined or a rejection selects the legacy pruning path. */\n\treadonly getGitIgnoreWatchInputs?: (\n\t\trepoPath: string,\n\t\tgitDir: GitDir,\n\t\toptions?: { refreshConfig?: boolean },\n\t) => Promise<GitIgnoreWatchInputs | undefined>;\n\t/**\n\t * Returns the absolute, normalized folders whose worktrees are ignored (see `GitProvider.getIgnoredWorktreeRoots`):\n\t * with a `readFile` and a `readDirectory`, the watcher's reports of their admin entries reach no session. Asked\n\t * once per common git dir, when its first session starts watching, and never without both. When absent, empty or\n\t * rejected, no admin entry is read.\n\t */\n\treadonly getIgnoredWorktreeRoots?: (repoPath: string) => Promise<readonly string[]>;\n\t/**\n\t * Returns the folders whose worktrees are ignored, relative to a repository's common git dir (see\n\t * `GitProvider.getIgnoredWorktreeFolders`): the `.git` watchers whose tree holds the common git dir leave\n\t * them unwatched. Asked once per common git dir, when its first session starts watching.\n\t */\n\treadonly getIgnoredWorktreeFolders?: (repoPath: string) => readonly string[];\n\t/** Opts into polling the watchers that report they can't be trusted. When absent, no watcher is asked. */\n\treadonly polling?: WatchPollingOptions;\n\t/**\n\t * Reads a file's bytes; a rejection means it couldn't be read. With it, each report of a repository's shared\n\t * `.git/config` is classified by what changed in the file: a change confined to some branches' `branch.<name>`\n\t * sections reaches only the subscribers following those branches, and carries no `remotes`. Without it, every\n\t * config change concerns everyone, as before.\n\t */\n\treadonly readFile?: (path: string) => Promise<Uint8Array>;\n\t/**\n\t * Returns a directory's entries with their types, as the host file system's `readDirectory` does; only the\n\t * directories count as admin entries (a stray `.DS_Store` is no worktree's). A rejection means it couldn't be\n\t * listed, and one whose `code` is `ENOENT` or `FileNotFound` that the directory isn't there. With it and a\n\t * `readFile`, the admin entries of a repository's worktrees are listed and read once as its first session starts\n\t * watching, so the reports of an ignored worktree's (see `getIgnoredWorktreeRoots`) reach no session, and the others\n\t * aren't held back.\n\t */\n\treadonly readDirectory?: (path: string) => Promise<readonly (readonly [string, number])[]>;\n}\n\nexport interface WatchHooks {\n\t/** Called when FETCH_HEAD changed (for last-fetched tracking) */\n\treadonly onFetchHeadChanged?: (repoPath: string) => void;\n\t/** Called when .git/info/exclude changed */\n\treadonly onIgnoresChanged?: (repoPath: string) => void;\n\t/** Called when .gitignore changed in the working tree (extension watches this separately) */\n\treadonly onGitIgnoreChanged?: (repoPath: string) => void;\n}\n\nexport interface WatchHandle {\n\treadonly session: RepositoryWatchSession;\n\tdispose(): void;\n}\n\ninterface SessionRecord {\n\treadonly session: RepositoryWatchSession;\n\treadonly gitDir: GitDir;\n\t/**\n\t * Hooks contributed by all current `watch()` callers for this repo path. Earlier\n\t * implementations stored just the first caller's hooks (`WatchHooks | undefined`) and\n\t * silently dropped subsequent callers' hooks — that broke the case where a low-level\n\t * subscriber (e.g. the Graph's secondary-worktree WIP watcher) opened the session\n\t * first without hooks, and a later `Repository.watch()` for the same path lost\n\t * its `markFetched` / `onIgnoresChanged` wiring. Each `watch()` call adds its hooks\n\t * to this set and removes them on dispose; fire sites iterate the set.\n\t */\n\treadonly watchHooks: Set<WatchHooks>;\n\trefCount: number;\n\t/** The mode {@link RepositoryWatchService.onDidChangeWatchMode} last announced; `'events'` while unwatched */\n\twatchMode: 'events' | 'poll';\n}\n\n/**\n * Global service that multiplexes repository watching across all repos.\n *\n * Manages:\n * - Session map: one `RepositoryWatchSession` per repo path (ref-counted)\n * - Watch groups: shared `.git` watchers across worktrees\n * - Working tree watchers: per-repo filesystem watchers with gitignore filtering\n *\n * Sessions and watch groups are created lazily on first `subscribe()`\n * within a session, and destroyed when the last subscriber leaves.\n */\nexport class RepositoryWatchService implements UnifiedDisposable {\n\tprivate readonly _onDidChangeRepository = new Emitter<WatcherRepoChangeEvent>();\n\t/** Global multiplexed event for ALL watched repos */\n\tget onDidChangeRepository(): Event<WatcherRepoChangeEvent> {\n\t\treturn this._onDidChangeRepository.event;\n\t}\n\n\tprivate readonly _onDidChangeWorkingTree = new Emitter<string>();\n\t/** Global multiplexed working-tree change event (repo path) for ALL watched repos. Fires once per\n\t * debounced flush per session — the single point that drives the cache's status clock for working-tree edits. */\n\tget onDidChangeWorkingTree(): Event<string> {\n\t\treturn this._onDidChangeWorkingTree.event;\n\t}\n\n\tprivate readonly _onDidChangeFetchHead = new Emitter<string>();\n\t/**\n\t * Global FETCH_HEAD change event (repo path) for ALL watched repos, fired as each change is seen (no debounce).\n\t * FETCH_HEAD maps to no {@link RepositoryChange} on the session, so this is how a host invalidates its cached\n\t * last-fetched time — the standalone service bridges it to the cache's `lastFetched`.\n\t */\n\tget onDidChangeFetchHead(): Event<string> {\n\t\treturn this._onDidChangeFetchHead.event;\n\t}\n\n\tprivate readonly _onDidChangeWatchMode = new Emitter<{ repoPath: string; mode: 'events' | 'poll' }>();\n\t/**\n\t * Fires as a watched repository starts being polled in place of a watcher (see {@link getWatchMode}), and with\n\t * `'events'` as it is watched natively again. Never fires as the repository stops being watched; one watched again\n\t * later starts from `'events'`.\n\t */\n\tget onDidChangeWatchMode(): Event<{ repoPath: string; mode: 'events' | 'poll' }> {\n\t\treturn this._onDidChangeWatchMode.event;\n\t}\n\n\tprivate readonly _onDidChangeRepoWatched = new Emitter<{ repoPath: string; watched: boolean }>();\n\t/**\n\t * Fires as a repository's `.git` directory starts being watched (its session's first repo subscriber connected it\n\t * to its watch group) and as it stops (its last one left, or its session was disposed); see {@link isRepoWatched}.\n\t * `repoPath` is the session's key ({@link getRepositoryKey}). Never fires as the service itself is disposed, nor as\n\t * the session suspends or resumes: a suspended session still reports what it held once it resumes, so there is\n\t * nothing to hand off, and {@link isRepoWatched} answers `false` meanwhile without announcing it.\n\t */\n\tget onDidChangeRepoWatched(): Event<{ repoPath: string; watched: boolean }> {\n\t\treturn this._onDidChangeRepoWatched.event;\n\t}\n\n\tprivate readonly defaultRepoDelayMs?: number;\n\tprivate readonly defaultWorkingTreeDelayMs?: number;\n\tprivate readonly defaultRepoMaxWaitMs?: number;\n\tprivate readonly defaultWorkingTreeMaxWaitMs?: number;\n\tprivate readonly getIgnoreFilter?: (repoPath: string, gitDirPath: string) => GitIgnoreFilter | undefined;\n\tprivate readonly getIgnoredDirectories?: (repoPath: string) => Promise<readonly string[]>;\n\tprivate readonly getGitIgnoreWatchInputs?: WatchServiceOptions['getGitIgnoreWatchInputs'];\n\tprivate readonly getIgnoredWorktreeRoots?: (repoPath: string) => Promise<readonly string[]>;\n\tprivate readonly getIgnoredWorktreeFolders?: (repoPath: string) => readonly string[];\n\tprivate readonly provider: FileWatchingProvider;\n\tprivate readonly poller: GitDirPoller | undefined;\n\tprivate readonly readFile: ((path: string) => Promise<Uint8Array>) | undefined;\n\tprivate readonly readDirectory: ((path: string) => Promise<readonly (readonly [string, number])[]>) | undefined;\n\n\tprivate readonly sessionMap = new Map<string, SessionRecord>();\n\tprivate readonly watchGroups = new Map<string, WatchGroup>();\n\tprivate readonly wtWatchers = new Map<string, WorkingTreeWatcherEntry>();\n\t/**\n\t * The last git-ignored directory read under each filter's current rules, kept across a working-tree watcher's\n\t * stop and start so a restart can skip the read; dropped with the filter\n\t */\n\tprivate readonly keptIgnoredDirectories = new WeakMap<GitIgnoreFilter, readonly string[]>();\n\tprivate _disposed = false;\n\t/** Global suspend state (driven by window focus); inherited by sessions created via {@link watch}. */\n\tprivate _suspended = false;\n\n\tconstructor(options: WatchServiceOptions) {\n\t\tthis.provider = options.watchingProvider;\n\t\tthis.defaultRepoDelayMs = options.defaultRepoDelayMs;\n\t\tthis.defaultWorkingTreeDelayMs = options.defaultWorkingTreeDelayMs;\n\t\tthis.defaultRepoMaxWaitMs = options.defaultRepoMaxWaitMs;\n\t\tthis.defaultWorkingTreeMaxWaitMs = options.defaultWorkingTreeMaxWaitMs;\n\t\tthis.getIgnoreFilter = options.getIgnoreFilter;\n\t\tthis.getIgnoredDirectories = options.getIgnoredDirectories;\n\t\tthis.getGitIgnoreWatchInputs = options.getGitIgnoreWatchInputs;\n\t\tthis.getIgnoredWorktreeRoots = options.getIgnoredWorktreeRoots;\n\t\tthis.getIgnoredWorktreeFolders = options.getIgnoredWorktreeFolders;\n\t\tthis.readFile = options.readFile;\n\t\tthis.readDirectory = options.readDirectory;\n\t\tif (options.polling != null) {\n\t\t\tthis.poller = new GitDirPoller(options.polling);\n\t\t}\n\t}\n\n\t[Symbol.dispose](): void {\n\t\tthis.dispose();\n\t}\n\n\tdispose(): void {\n\t\tif (this._disposed) return;\n\n\t\tthis._disposed = true;\n\n\t\tfor (const record of this.sessionMap.values()) {\n\t\t\tthis.disposeSessionRecord(record);\n\t\t}\n\t\tthis.sessionMap.clear();\n\n\t\tfor (const group of this.watchGroups.values()) {\n\t\t\tgroup.dispose();\n\t\t}\n\t\tthis.watchGroups.clear();\n\n\t\tfor (const repoPath of [...this.wtWatchers.keys()]) {\n\t\t\tthis.stopWorkingTreeWatcher(repoPath);\n\t\t}\n\n\t\tthis.poller?.dispose();\n\n\t\tthis._onDidChangeRepository.dispose();\n\t\tthis._onDidChangeWorkingTree.dispose();\n\t\tthis._onDidChangeFetchHead.dispose();\n\t\tthis._onDidChangeWatchMode.dispose();\n\t\tthis._onDidChangeRepoWatched.dispose();\n\t}\n\n\t/**\n\t * Start watching a repository. Reference-counted:\n\t * same repoPath → same session (refCount++).\n\t * Worktrees sharing a .git dir share the WatchGroup.\n\t *\n\t * Returns a handle with the session and a dispose function.\n\t * Disposing the handle decrements the ref count.\n\t *\n\t * `repoPath` is keyed by {@link getRepositoryKey}, and every session, event and hook carries that key — the\n\t * same one the cache fences status reads on — so a host passing `C:\\repo\\` and one passing `c:/repo` share\n\t * a session and advance the same status clock.\n\t */\n\twatch(repoPath: string, gitDir: GitDir, watchHooks?: WatchHooks): WatchHandle | undefined {\n\t\tif (this._disposed) return undefined;\n\n\t\trepoPath = getRepositoryKey(repoPath);\n\n\t\tlet record = this.sessionMap.get(repoPath);\n\t\tif (record != null) {\n\t\t\trecord.refCount++;\n\t\t\tif (watchHooks != null) {\n\t\t\t\trecord.watchHooks.add(watchHooks);\n\t\t\t}\n\t\t} else {\n\t\t\tconst session = new RepositoryWatchSession({\n\t\t\t\trepoPath: repoPath,\n\t\t\t\tdefaultRepoDelayMs: this.defaultRepoDelayMs,\n\t\t\t\tdefaultWorkingTreeDelayMs: this.defaultWorkingTreeDelayMs,\n\t\t\t\tdefaultRepoMaxWaitMs: this.defaultRepoMaxWaitMs,\n\t\t\t\tdefaultWorkingTreeMaxWaitMs: this.defaultWorkingTreeMaxWaitMs,\n\t\t\t\tsuspended: this._suspended,\n\t\t\t\tlifecycle: {\n\t\t\t\t\tonFirstRepoSubscriber: (): void => {\n\t\t\t\t\t\tconst rec = this.sessionMap.get(repoPath);\n\t\t\t\t\t\tif (rec != null) {\n\t\t\t\t\t\t\tthis.connectToWatchGroup(rec);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tonLastRepoSubscriber: (): void => {\n\t\t\t\t\t\tconst rec = this.sessionMap.get(repoPath);\n\t\t\t\t\t\tif (rec != null) {\n\t\t\t\t\t\t\tconst entry = this.wtWatchers.get(repoPath);\n\t\t\t\t\t\t\tif (entry?.delegation != null) {\n\t\t\t\t\t\t\t\tthis.relinquishIgnoreDelegation(entry);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tthis.disconnectFromWatchGroup(rec);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tonFirstWorkingTreeSubscriber: (): void => {\n\t\t\t\t\t\tconst rec = this.sessionMap.get(repoPath);\n\t\t\t\t\t\tif (rec != null) {\n\t\t\t\t\t\t\tthis.startWorkingTreeWatcher(rec);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tonLastWorkingTreeSubscriber: (): void => {\n\t\t\t\t\t\tthis.stopWorkingTreeWatcher(repoPath);\n\t\t\t\t\t\tconst rec = this.sessionMap.get(repoPath);\n\t\t\t\t\t\tif (rec != null) {\n\t\t\t\t\t\t\tthis.updateWatchMode(rec);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tonDidFireRepoChange: (event): void => {\n\t\t\t\t\tthis._onDidChangeRepository.fire(event);\n\t\t\t\t\tconst entry = this.wtWatchers.get(repoPath);\n\t\t\t\t\tif (entry?.delegation == null) return;\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tevent.changes.has('index') ||\n\t\t\t\t\t\tevent.changes.has('head') ||\n\t\t\t\t\t\t(event.changes.has('config') && !event.configConfined)\n\t\t\t\t\t) {\n\t\t\t\t\t\tthis.refreshWorkingTreeFilter(repoPath);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tonDidFireWorkingTreeChange: (repoPath): void => {\n\t\t\t\t\tthis._onDidChangeWorkingTree.fire(repoPath);\n\t\t\t\t},\n\t\t\t});\n\n\t\t\tconst watchHooksSet = new Set<WatchHooks>();\n\t\t\tif (watchHooks != null) {\n\t\t\t\twatchHooksSet.add(watchHooks);\n\t\t\t}\n\n\t\t\trecord = {\n\t\t\t\tsession: session,\n\t\t\t\tgitDir: gitDir,\n\t\t\t\twatchHooks: watchHooksSet,\n\t\t\t\trefCount: 1,\n\t\t\t\twatchMode: 'events',\n\t\t\t};\n\t\t\tthis.sessionMap.set(repoPath, record);\n\t\t}\n\n\t\tconst sessionRef = record.session;\n\t\tlet handleDisposed = false;\n\n\t\treturn {\n\t\t\tsession: sessionRef,\n\t\t\tdispose: (): void => {\n\t\t\t\tif (handleDisposed) return;\n\n\t\t\t\thandleDisposed = true;\n\n\t\t\t\tconst rec = this.sessionMap.get(repoPath);\n\t\t\t\tif (rec == null) return;\n\n\t\t\t\trec.refCount--;\n\t\t\t\tif (watchHooks != null) {\n\t\t\t\t\trec.watchHooks.delete(watchHooks);\n\t\t\t\t}\n\t\t\t\tif (rec.refCount <= 0) {\n\t\t\t\t\tthis.sessionMap.delete(repoPath);\n\t\t\t\t\tthis.disposeSessionRecord(rec);\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t}\n\n\t/**\n\t * Core announced one of its own writes for `repoPath`; the session watching it fires the announcement in place of\n\t * the write's own `.git` events (see {@link RepositoryWatchSession.noteSelfWrite}); `refs` are the full ref names it\n\t * moved, when it knows them, and `options.configConfinedToRefs` confines its `config` change to the sections of the\n\t * local branches among them (see `GitServiceHooks.repository.onChanged`); `options.movedWorktrees` confines its\n\t * `worktreeHead` change to those linked worktrees (see `AnnouncedRepositoryChanges.movedWorktrees`). A path no session\n\t * watches is ignored.\n\t */\n\tnoteSelfWrite(\n\t\trepoPath: string,\n\t\tchanges: readonly RepositoryChange[],\n\t\trefs?: readonly string[],\n\t\toptions?: { readonly configConfinedToRefs?: boolean; readonly movedWorktrees?: readonly string[] },\n\t): void {\n\t\tif (this._disposed) return;\n\n\t\tthis.sessionMap.get(getRepositoryKey(repoPath))?.session.noteSelfWrite(changes, refs, options);\n\t}\n\n\t/**\n\t * Whether `repoPath`'s `.git` directory is watched: its session has a repo subscriber, so it is connected to its\n\t * watch group (natively, or polled in place of a watcher that can't be trusted). A session with only working-tree\n\t * subscribers, or none, doesn't count, nor does a suspended one: it holds what its watcher hears until it resumes,\n\t * and the poller doesn't poll meanwhile, so a read is served stale. Suspending or resuming announces nothing (see\n\t * {@link onDidChangeRepoWatched}).\n\t */\n\tisRepoWatched(repoPath: string): boolean {\n\t\tconst record = this.sessionMap.get(getRepositoryKey(repoPath));\n\t\treturn record != null && this.isConnected(record) && !record.session.suspended;\n\t}\n\n\t/** Get an existing session by repo path */\n\tgetSession(repoPath: string): RepositoryWatchSession | undefined {\n\t\treturn this.sessionMap.get(getRepositoryKey(repoPath))?.session;\n\t}\n\n\t/**\n\t * Whether the working tree's watch has yet to go live, owing a rescan once it does (see\n\t * `FileWatchingProvider.callsOnDidStart`). Not while it's `unwatchable`: it rescans when it comes back.\n\t */\n\tisWorkingTreeStarting(repoPath: string): boolean {\n\t\tconst entry = this.wtWatchers.get(getRepositoryKey(repoPath));\n\t\treturn entry?.starting === true && entry.reliability !== 'unwatchable';\n\t}\n\n\t/**\n\t * `'poll'` while a watcher the repository is watched through — its `.git` watchers or its working tree's — can't\n\t * watch, and is polled instead; `'events'` while it is watched natively (polled beside an `unreliable` watcher\n\t * included); `undefined` when nothing watches it, which {@link onDidChangeWatchMode} doesn't announce.\n\t */\n\tgetWatchMode(repoPath: string): 'events' | 'poll' | undefined {\n\t\tconst record = this.sessionMap.get(getRepositoryKey(repoPath));\n\t\treturn record != null ? this.computeWatchMode(record) : undefined;\n\t}\n\n\t/** Resource usage retained by repository watchers. */\n\tgetResourceUsage(): ResourceUsage {\n\t\tconst usage: ResourceUsage = {\n\t\t\t'watch.sessions.count': this.sessionMap.size,\n\t\t\t'watch.groups.count': this.watchGroups.size,\n\t\t\t'watch.workingTreeWatchers.count': this.wtWatchers.size,\n\t\t};\n\t\tif (this.poller != null) {\n\t\t\tusage['watch.pollTargets.count'] = this.poller.size;\n\t\t}\n\t\treturn usage;\n\t}\n\n\t/** Suspend all sessions and mark the service suspended so late-joining sessions start suspended */\n\tsuspendAll(): void {\n\t\tthis._suspended = true;\n\t\tfor (const record of this.sessionMap.values()) {\n\t\t\trecord.session.suspend();\n\t\t}\n\t\tthis.poller?.suspend();\n\t}\n\n\t/** Resume all sessions (clearing the global suspend state), with optional per-session delay */\n\tresumeAll(getDelay?: (session: RepositoryWatchSession) => number): void {\n\t\tthis._suspended = false;\n\t\tfor (const record of this.sessionMap.values()) {\n\t\t\tconst delayMs = getDelay?.(record.session);\n\t\t\trecord.session.resume(delayMs);\n\t\t\tif (this.poller == null) {\n\t\t\t\tconst entry = this.wtWatchers.get(record.session.repoPath);\n\t\t\t\tif (entry != null && entry.watcher == null) {\n\t\t\t\t\tthis.placeFallbackWorkingTreeWatcher(entry);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthis.poller?.resume();\n\t}\n\n\tprivate getOrCreateWatchGroup(commonGitDir: string, repoPath: string): WatchGroup {\n\t\tlet group = this.watchGroups.get(commonGitDir);\n\t\tif (group == null) {\n\t\t\tgroup = new WatchGroup(\n\t\t\t\tcommonGitDir,\n\t\t\t\tthis.provider,\n\t\t\t\tthis.poller,\n\t\t\t\tthis.readFile,\n\t\t\t\tthis.readDirectory,\n\t\t\t\t// Only a group that can read the admin entries waits on the folders; asking otherwise reads for nothing,\n\t\t\t\t// and leaves a rejection unhandled\n\t\t\t\tthis.readFile != null && this.readDirectory != null\n\t\t\t\t\t? this.getIgnoredWorktreeRoots?.(repoPath)\n\t\t\t\t\t: undefined,\n\t\t\t\tthis.getIgnoredWorktreeFolders?.(repoPath),\n\t\t\t);\n\t\t\tthis.watchGroups.set(commonGitDir, group);\n\t\t}\n\t\treturn group;\n\t}\n\n\tprivate maybeDisposeWatchGroup(commonGitDir: string): void {\n\t\tconst group = this.watchGroups.get(commonGitDir);\n\t\tif (group == null) return;\n\n\t\tif (group.sessions.size === 0) {\n\t\t\tgroup.dispose();\n\t\t\tthis.watchGroups.delete(commonGitDir);\n\t\t}\n\t}\n\n\tprivate connectToWatchGroup(record: SessionRecord): void {\n\t\tconst { session, gitDir, watchHooks } = record;\n\t\tconst commonGitDir = (gitDir.commonUri ?? gitDir.uri).fsPath;\n\t\tconst group = this.getOrCreateWatchGroup(commonGitDir, session.repoPath);\n\n\t\tconst hooks: WatchGroupHooks = {\n\t\t\tonRepoChanged: (\n\t\t\t\t_repoPath: string,\n\t\t\t\tchanges: RepositoryChange[],\n\t\t\t\tref?: string | false,\n\t\t\t\toverflow?: boolean,\n\t\t\t\tconfigBranches?: ReadonlySet<string>,\n\t\t\t\tmovedWorktree?: string,\n\t\t\t): void => {\n\t\t\t\tif (overflow) {\n\t\t\t\t\tsession.pushUnfencedRepoChanges(changes);\n\t\t\t\t\tconst entry = this.wtWatchers.get(session.repoPath);\n\t\t\t\t\tif (entry?.delegation != null) {\n\t\t\t\t\t\tthis.scheduleIgnorePruningRefresh(entry, 'recovery');\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tsession.pushRepoChanges(changes, ref, configBranches, movedWorktree);\n\t\t\t\t}\n\n\t\t\t\t// A working tree nothing watches is read again whenever the index or HEAD says it may have moved\n\t\t\t\tif (\n\t\t\t\t\tthis.poller != null &&\n\t\t\t\t\t(changes.includes('index') || changes.includes('head')) &&\n\t\t\t\t\tthis.wtWatchers.get(session.repoPath)?.reliability === 'unwatchable'\n\t\t\t\t) {\n\t\t\t\t\tsession.pushWorkingTreeChanges([], true);\n\t\t\t\t}\n\t\t\t},\n\t\t\tonFetchHeadChanged: (repoPath: string): void => {\n\t\t\t\t// Global first, so a host's cache drops its last-fetched time before any hook re-reads it\n\t\t\t\tthis._onDidChangeFetchHead.fire(repoPath);\n\t\t\t\t// Iterate at fire time so callers that joined after the group was wired up\n\t\t\t\t// still receive events (e.g. a `Repository.watch()` whose hooks landed\n\t\t\t\t// after a hookless `GitRepositoryService.watch` registered first).\n\t\t\t\tfor (const h of watchHooks) {\n\t\t\t\t\th.onFetchHeadChanged?.(repoPath);\n\t\t\t\t}\n\t\t\t},\n\t\t\tonIgnoresChanged: (repoPath: string): void => {\n\t\t\t\tthis.refreshWorkingTreeFilter(repoPath);\n\t\t\t\tfor (const h of watchHooks) {\n\t\t\t\t\th.onIgnoresChanged?.(repoPath);\n\t\t\t\t}\n\t\t\t},\n\t\t\tgetProbeRefs: (): Iterable<string> => {\n\t\t\t\tconst refs = session.getRelevantRefs();\n\t\t\t\tfor (const ref of this.poller?.options.getRefs?.(session.repoPath) ?? []) {\n\t\t\t\t\trefs.add(ref);\n\t\t\t\t}\n\t\t\t\treturn refs;\n\t\t\t},\n\t\t\tonUnwatchableChanged: (): void => this.updateWatchMode(record),\n\t\t};\n\n\t\tconst wasConnected = group.sessions.has(session.repoPath);\n\t\tgroup.addSession(session.repoPath, gitDir, hooks);\n\t\tthis.updateWatchMode(record);\n\t\tif (!wasConnected) {\n\t\t\tthis.fireRepoWatchedIfConnected(record, true);\n\t\t}\n\t}\n\n\tprivate disconnectFromWatchGroup(record: SessionRecord): void {\n\t\tconst { session, gitDir } = record;\n\t\tconst commonGitDir = (gitDir.commonUri ?? gitDir.uri).fsPath;\n\t\tconst group = this.watchGroups.get(commonGitDir);\n\t\tif (group == null) return;\n\n\t\tconst wasConnected = group.sessions.has(session.repoPath);\n\t\tgroup.removeSession(session.repoPath);\n\t\tthis.maybeDisposeWatchGroup(commonGitDir);\n\t\tthis.updateWatchMode(record);\n\t\tif (wasConnected) {\n\t\t\tthis.fireRepoWatchedIfConnected(record, false);\n\t\t}\n\t}\n\n\tprivate isConnected(record: SessionRecord): boolean {\n\t\tconst group = this.watchGroups.get((record.gitDir.commonUri ?? record.gitDir.uri).fsPath);\n\t\treturn group?.sessions.has(record.session.repoPath) ?? false;\n\t}\n\n\t/** Announces that `record` was just connected (`watched`) or disconnected, once that is what it is */\n\tprivate fireRepoWatchedIfConnected(record: SessionRecord, watched: boolean): void {\n\t\tif (this._disposed || this.isConnected(record) !== watched) return;\n\n\t\tthis._onDidChangeRepoWatched.fire({ repoPath: record.session.repoPath, watched: watched });\n\t}\n\n\tprivate computeWatchMode(record: SessionRecord): 'events' | 'poll' | undefined {\n\t\tconst repoPath = record.session.repoPath;\n\t\tconst group = this.watchGroups.get((record.gitDir.commonUri ?? record.gitDir.uri).fsPath);\n\t\tconst connected = group?.sessions.has(repoPath) ?? false;\n\t\tconst wt = this.wtWatchers.get(repoPath);\n\t\tif (!connected && wt == null) return undefined;\n\t\tif (this.poller == null && wt?.watcher == null) return connected ? 'events' : undefined;\n\n\t\treturn group?.isUnwatchable(repoPath) || wt?.reliability === 'unwatchable' ? 'poll' : 'events';\n\t}\n\n\tprivate updateWatchMode(record: SessionRecord): void {\n\t\tif (this._disposed) return;\n\n\t\tconst mode = this.computeWatchMode(record);\n\t\tif (mode == null) {\n\t\t\trecord.watchMode = 'events';\n\t\t\treturn;\n\t\t}\n\t\tif (mode === record.watchMode) return;\n\n\t\trecord.watchMode = mode;\n\t\tthis._onDidChangeWatchMode.fire({ repoPath: record.session.repoPath, mode: mode });\n\t}\n\n\tprivate startWorkingTreeWatcher(record: SessionRecord): void {\n\t\tconst { session, gitDir, watchHooks } = record;\n\t\tconst repoPath = session.repoPath;\n\t\tif (this.wtWatchers.has(repoPath)) return;\n\n\t\tconst canPrune = this.canPruneIgnoredDirectories();\n\t\tlet entry: WorkingTreeWatcherEntry | undefined;\n\n\t\tlet filter: GitIgnoreFilter | undefined;\n\t\tif (this.getIgnoreFilter != null) {\n\t\t\tfilter = this.getIgnoreFilter(repoPath, gitDir.uri.fsPath);\n\t\t}\n\n\t\tlet filterReady = filter == null;\n\t\tlet buffered: string[] | undefined = filter != null ? [] : undefined;\n\t\tlet bufferIncomplete = false;\n\n\t\tconst revalidated = filter?.revalidate();\n\t\tif (filter != null) {\n\t\t\tconst replay = (): void => {\n\t\t\t\tconst pending = buffered;\n\t\t\t\tconst incomplete = bufferIncomplete;\n\t\t\t\tfilterReady = true;\n\t\t\t\tbuffered = undefined;\n\t\t\t\tbufferIncomplete = false;\n\n\t\t\t\tif (!pending?.length) return;\n\n\t\t\t\tconst paths = filterWorkingTreePaths(pending, repoPath, filter);\n\t\t\t\tif (paths.length > 0 || incomplete) {\n\t\t\t\t\tsession.pushWorkingTreeChanges(paths, incomplete);\n\t\t\t\t}\n\t\t\t};\n\t\t\tvoid filter\n\t\t\t\t.ready()\n\t\t\t\t.then(replay, replay)\n\t\t\t\t.catch(() => {});\n\t\t}\n\n\t\tconst onIgnoreRulesChanged = (refreshFilter: boolean, reason: 'worktree' | 'recovery' = 'worktree'): void => {\n\t\t\tif (refreshFilter && filter != null) {\n\t\t\t\tvoid filter.refresh();\n\t\t\t}\n\t\t\tif (entry != null) {\n\t\t\t\tthis.scheduleIgnorePruningRefresh(entry, reason);\n\t\t\t}\n\t\t\tfor (const h of watchHooks) {\n\t\t\t\th.onGitIgnoreChanged?.(repoPath);\n\t\t\t}\n\t\t\tsession.pushUnfencedRepoChanges(['ignores']);\n\t\t};\n\n\t\tconst isNoise = createWorkingTreeNoiseFilter(repoPath);\n\n\t\tconst onEvent = (event: FileWatchEvent): void => {\n\t\t\tconst startingDelegation = entry?.starting === true && entry.delegation != null;\n\t\t\tif (event.reason === 'overflow') {\n\t\t\t\tsession.pushWorkingTreeChanges([], true);\n\t\t\t\tonIgnoreRulesChanged(true, 'recovery');\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (isNoise(event.path)) return;\n\n\t\t\tconst relativePath = isDescendant(event.path, repoPath) ? relative(repoPath, event.path) : undefined;\n\t\t\tif (relativePath === '.gitignore') {\n\t\t\t\tonIgnoreRulesChanged(true);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\trelativePath?.endsWith('/.gitignore') &&\n\t\t\t\t(entry?.delegation != null ||\n\t\t\t\t\t!(filterReady && filter?.isIgnored(relativePath.slice(0, -'.gitignore'.length))))\n\t\t\t) {\n\t\t\t\tonIgnoreRulesChanged(true);\n\t\t\t}\n\n\t\t\tif (startingDelegation) return;\n\n\t\t\tif (!filterReady) {\n\t\t\t\tif (buffered != null && buffered.length >= maxBufferedWorkingTreePaths) {\n\t\t\t\t\tbufferIncomplete = true;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tbuffered?.push(event.path);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (filter != null && relativePath != null && filter.isIgnored(relativePath)) {\n\t\t\t\tif (canPrune && entry != null && entry.delegation == null) {\n\t\t\t\t\tthis.onIgnoredEvent(entry, filter, relativePath);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tsession.pushWorkingTreeChanges([event.path]);\n\t\t};\n\n\t\tconst kept = canPrune && filter != null ? this.keptIgnoredDirectories.get(filter) : undefined;\n\t\tconst created = this.createWorkingTreeWatcher(\n\t\t\trepoPath,\n\t\t\tonEvent,\n\t\t\tkept != null ? [...workingTreeExcludes, ...kept] : workingTreeExcludes,\n\t\t\tthis.getGitIgnoreWatchInputs != null && this.isConnected(record),\n\t\t);\n\t\tentry = {\n\t\t\tsession: session,\n\t\t\tonEvent: onEvent,\n\t\t\tfilter: filter,\n\t\t\twatcher: created.watcher,\n\t\t\tdelegation: created.delegation,\n\t\t\tignoredDirectories: created.delegation == null ? (kept ?? []) : [],\n\t\t\tgeneration: 0,\n\t\t\treading: false,\n\t\t\trereadQueued: false,\n\t\t\treliability: 'reliable',\n\t\t\tstarting: created.awaitingStartAck || created.delegation != null,\n\t\t\tawaitingStartAck: created.awaitingStartAck,\n\t\t};\n\t\tthis.wtWatchers.set(repoPath, entry);\n\t\tthis.reconcileWorkingTreeLifecycle(entry, created.reliability, { initial: true });\n\n\t\tif (entry.delegation != null || (canPrune && kept == null)) {\n\t\t\tthis.refreshIgnorePruning(entry);\n\t\t}\n\n\t\tvoid revalidated?.then(\n\t\t\tchanged => {\n\t\t\t\tif (!changed) return;\n\n\t\t\t\tif (filter != null) {\n\t\t\t\t\tthis.keptIgnoredDirectories.delete(filter);\n\t\t\t\t}\n\t\t\t\tif (this.wtWatchers.get(repoPath) === entry) {\n\t\t\t\t\tonIgnoreRulesChanged(false);\n\t\t\t\t}\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tif (filter != null) {\n\t\t\t\t\tthis.keptIgnoredDirectories.delete(filter);\n\t\t\t\t}\n\t\t\t\tif (this.wtWatchers.get(repoPath) === entry) {\n\t\t\t\t\tonIgnoreRulesChanged(true);\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\t}\n\n\tprivate stopWorkingTreeWatcher(repoPath: string): void {\n\t\tconst entry = this.wtWatchers.get(repoPath);\n\t\tif (entry == null) return;\n\n\t\tentry.generation++;\n\t\tclearTimeout(entry.refreshTimer);\n\t\tentry.refreshTimer = undefined;\n\t\tthis.wtWatchers.delete(repoPath);\n\t\tentry.watcher?.dispose();\n\t\tif (entry.pollTarget != null) {\n\t\t\tthis.poller?.delete(entry.pollTarget);\n\t\t\tentry.pollTarget = undefined;\n\t\t}\n\t}\n\n\tprivate createWorkingTreeWatcher(\n\t\trepoPath: string,\n\t\tonEvent: (event: FileWatchEvent) => void,\n\t\texcludes: readonly string[],\n\t\ttryDelegation = false,\n\t): CreatedWorkingTreeWatcher {\n\t\tlet watcher: FileWatcher | undefined;\n\t\tlet started = false;\n\t\tconst onDidStart = (): void => {\n\t\t\tif (started) return;\n\n\t\t\tstarted = true;\n\t\t\tconst entry = this.wtWatchers.get(repoPath);\n\t\t\tif (watcher != null && entry?.watcher === watcher) {\n\t\t\t\tentry.awaitingStartAck = false;\n\t\t\t\tthis.reconcileWorkingTreeLifecycle(entry, entry.reliability, { rescan: entry.delegation == null });\n\t\t\t}\n\t\t};\n\n\t\tlet reliability: FileWatcherReliability = 'reliable';\n\t\tconst onDidChangeReliability = (state: FileWatcherReliability): void => {\n\t\t\tif (watcher == null) {\n\t\t\t\treliability = state;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst entry = this.wtWatchers.get(repoPath);\n\t\t\tif (entry?.watcher === watcher) {\n\t\t\t\tthis.reconcileWorkingTreeLifecycle(entry, state);\n\t\t\t}\n\t\t};\n\t\tconst options: FileWatcherOptions = {\n\t\t\texcludes: excludes,\n\t\t\tonDidStart: onDidStart,\n\t\t\t...(this.poller == null ? undefined : { onDidChangeReliability: onDidChangeReliability }),\n\t\t};\n\t\tif (tryDelegation && this.provider.createGitIgnoringWatcher != null) {\n\t\t\tlet declined = false;\n\t\t\tconst delegated = this.provider.createGitIgnoringWatcher(\n\t\t\t\trepoPath,\n\t\t\t\tevent => {\n\t\t\t\t\tconst entry = this.wtWatchers.get(repoPath);\n\t\t\t\t\tif (watcher != null && entry?.watcher === watcher && !declined) {\n\t\t\t\t\t\tonEvent(event);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\t{\n\t\t\t\t\texcludes: workingTreeExcludes,\n\t\t\t\t\tonDidStart: () => {\n\t\t\t\t\t\tif (!declined) {\n\t\t\t\t\t\t\tonDidStart();\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\t...(this.poller == null\n\t\t\t\t\t\t? undefined\n\t\t\t\t\t\t: {\n\t\t\t\t\t\t\t\tonDidChangeReliability: (state: FileWatcherReliability) => {\n\t\t\t\t\t\t\t\t\tif (!declined) {\n\t\t\t\t\t\t\t\t\t\tonDidChangeReliability(state);\n\t\t\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t}),\n\t\t\t\t},\n\t\t\t);\n\t\t\tif (delegated != null) {\n\t\t\t\twatcher = delegated;\n\t\t\t\treturn {\n\t\t\t\t\twatcher: watcher,\n\t\t\t\t\treliability: reliability,\n\t\t\t\t\tawaitingStartAck: this.provider.callsOnDidStart === true && !started,\n\t\t\t\t\tdelegation: {\n\t\t\t\t\t\twatcher: delegated,\n\t\t\t\t\t\tinitialApplied: false,\n\t\t\t\t\t\trefreshing: false,\n\t\t\t\t\t\tverified: false,\n\t\t\t\t\t},\n\t\t\t\t};\n\t\t\t}\n\n\t\t\tdeclined = true;\n\t\t\tstarted = false;\n\t\t\treliability = 'reliable';\n\t\t}\n\n\t\twatcher = this.provider.createWatcher(repoPath, '**', onEvent, options);\n\t\treturn {\n\t\t\twatcher: watcher,\n\t\t\treliability: reliability,\n\t\t\tawaitingStartAck: this.provider.callsOnDidStart === true && !started,\n\t\t};\n\t}\n\n\tprivate reconcileWorkingTreeLifecycle(\n\t\tentry: WorkingTreeWatcherEntry,\n\t\tstate: FileWatcherReliability,\n\t\toptions?: { initial?: boolean; rescan?: boolean },\n\t): void {\n\t\tconst unavailable = state === 'unwatchable';\n\t\tconst availabilityChanged = !options?.initial && unavailable !== (entry.reliability === 'unwatchable');\n\t\tconst delegation = entry.delegation;\n\t\tentry.reliability = state;\n\t\tif (unavailable) {\n\t\t\tentry.awaitingStartAck = false;\n\t\t}\n\n\t\tif (availabilityChanged && delegation != null) {\n\t\t\tif (unavailable) {\n\t\t\t\tentry.generation++;\n\t\t\t\tif (entry.starting) {\n\t\t\t\t\tdelegation.verified = false;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.refreshWorkingTreeFilter(entry.session.repoPath, 'recovery');\n\t\t\t}\n\t\t}\n\n\t\tconst rulesVerified = delegation?.verified !== false;\n\t\tconst startupReady = entry.starting && !unavailable && !entry.awaitingStartAck && rulesVerified;\n\t\tconst reconcileAvailability = availabilityChanged && (unavailable || rulesVerified);\n\t\tif (startupReady || (availabilityChanged && unavailable && delegation == null)) {\n\t\t\tentry.starting = false;\n\t\t}\n\n\t\tthis.updateWorkingTreePollTarget(entry);\n\t\tif (startupReady || reconcileAvailability || options?.rescan) {\n\t\t\tentry.session.pushWorkingTreeChanges([], true);\n\t\t}\n\n\t\tconst record = this.sessionMap.get(entry.session.repoPath);\n\t\tif (record != null) {\n\t\t\tthis.updateWatchMode(record);\n\t\t}\n\t}\n\n\t/** Polls the host's working-tree fingerprint, when it gives one, while the watcher isn't `reliable` */\n\tprivate updateWorkingTreePollTarget(entry: WorkingTreeWatcherEntry): void {\n\t\tconst poller = this.poller;\n\t\tconst getFingerprint = poller?.options.getWorkingTreeFingerprint;\n\t\tif (poller == null) return;\n\n\t\tif (entry.reliability === 'reliable' || (getFingerprint == null && entry.watcher != null)) {\n\t\t\tif (entry.pollTarget != null) {\n\t\t\t\tpoller.delete(entry.pollTarget);\n\t\t\t\tentry.pollTarget = undefined;\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (entry.pollTarget != null) return;\n\n\t\tconst repoPath = entry.session.repoPath;\n\t\tlet last: string | undefined;\n\t\tconst target: PollTarget = {\n\t\t\tpoll: async (): Promise<void> => {\n\t\t\t\tif (entry.pollTarget !== target) return;\n\n\t\t\t\tif (entry.watcher == null) {\n\t\t\t\t\tthis.placeFallbackWorkingTreeWatcher(entry);\n\t\t\t\t}\n\t\t\t\tif (getFingerprint == null || entry.pollTarget !== target) return;\n\n\t\t\t\tlet fingerprint: string | undefined;\n\t\t\t\ttry {\n\t\t\t\t\tfingerprint = await getFingerprint(repoPath);\n\t\t\t\t} catch {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (fingerprint == null || entry.pollTarget !== target) return;\n\n\t\t\t\tconst moved = last != null && last !== fingerprint;\n\t\t\t\tlast = fingerprint;\n\t\t\t\t// A fingerprint says the tree moved, not which files did\n\t\t\t\tif (moved) {\n\t\t\t\t\tentry.session.pushWorkingTreeChanges([], true);\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t\tentry.pollTarget = target;\n\t\tpoller.add(target);\n\t}\n\n\tprivate canPruneIgnoredDirectories(): boolean {\n\t\treturn this.provider.supportsExcludes === true && this.getIgnoredDirectories != null;\n\t}\n\n\t/**\n\t * An event the gitignore post-filter dropped. When its directory is itself ignored, the watcher is watching an\n\t * ignored directory it could prune (one created after the last read), so the ignored set is read again. An ignored\n\t * file in a watched directory (a root `.env`, `src/debug.log`) triggers nothing.\n\t */\n\tprivate onIgnoredEvent(entry: WorkingTreeWatcherEntry, filter: GitIgnoreFilter, relativePath: string): void {\n\t\tif (entry.refreshTimer != null || entry.rereadQueued) return;\n\n\t\tlet ignoredDir: string | undefined;\n\t\tfor (let slash = relativePath.indexOf('/'); slash !== -1; slash = relativePath.indexOf('/', slash + 1)) {\n\t\t\tconst dir = relativePath.slice(0, slash);\n\t\t\tif (entry.unpruned?.has(dir) || entry.unprunable?.has(dir)) return;\n\t\t\tif (filter.isIgnored(`${dir}/`)) {\n\t\t\t\tignoredDir = dir;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (ignoredDir == null) return;\n\n\t\tentry.unpruned ??= new Set();\n\t\tentry.unpruned.add(ignoredDir);\n\n\t\tif (entry.reading) {\n\t\t\tentry.rereadQueued = true;\n\t\t\treturn;\n\t\t}\n\n\t\tthis.armIgnorePruningRefresh(entry);\n\t}\n\n\tprivate scheduleIgnorePruningRefresh(\n\t\tentry: WorkingTreeWatcherEntry,\n\t\treason: Exclude<GitIgnoreRefreshReason, 'initial'>,\n\t): void {\n\t\tif (entry.filter != null) {\n\t\t\tthis.keptIgnoredDirectories.delete(entry.filter);\n\t\t}\n\t\tif (entry.delegation == null && !this.canPruneIgnoredDirectories()) return;\n\n\t\tconst delegation = entry.delegation;\n\t\tif (delegation != null) {\n\t\t\tif (entry.starting) {\n\t\t\t\tdelegation.verified = false;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tdelegation.pendingRefresh == null ||\n\t\t\t\tdelegation.pendingRefresh === 'worktree' ||\n\t\t\t\treason === 'recovery'\n\t\t\t) {\n\t\t\t\tdelegation.pendingRefresh = reason;\n\t\t\t}\n\t\t}\n\n\t\tentry.generation++;\n\t\tentry.unprunable = undefined;\n\t\tclearTimeout(entry.refreshTimer);\n\t\tthis.armIgnorePruningRefresh(entry);\n\t}\n\n\tprivate armIgnorePruningRefresh(entry: WorkingTreeWatcherEntry): void {\n\t\tentry.refreshTimer = setTimeout(() => {\n\t\t\tentry.refreshTimer = undefined;\n\t\t\tconst repoPath = entry.session.repoPath;\n\t\t\tif (this.wtWatchers.get(repoPath) !== entry) return;\n\n\t\t\tthis.refreshIgnorePruning(entry);\n\t\t}, ignorePruningRefreshDelayMs);\n\t}\n\n\tprivate refreshIgnorePruning(entry: WorkingTreeWatcherEntry): void {\n\t\tif (this.wtWatchers.get(entry.session.repoPath) !== entry) return;\n\n\t\tconst delegation = entry.delegation;\n\t\tif (delegation != null) {\n\t\t\tif (!delegation.refreshing && (!delegation.initialApplied || entry.reliability !== 'unwatchable')) {\n\t\t\t\tvoid this.refreshDelegatedIgnores(entry, delegation);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (entry.watcher == null || !this.canPruneIgnoredDirectories()) return;\n\t\tif (entry.reading) {\n\t\t\tentry.rereadQueued = true;\n\t\t\treturn;\n\t\t}\n\n\t\tvoid this.refreshIgnoredDirectories(entry);\n\t}\n\n\tprivate async refreshIgnoredDirectories(entry: WorkingTreeWatcherEntry): Promise<void> {\n\t\tconst getIgnoredDirectories = this.getIgnoredDirectories;\n\t\tif (getIgnoredDirectories == null) return;\n\n\t\tentry.reading = true;\n\t\ttry {\n\t\t\tconst generation = entry.generation;\n\t\t\tconst unpruned = entry.unpruned?.size ? [...entry.unpruned] : undefined;\n\n\t\t\tlet directories: readonly string[] | undefined;\n\t\t\ttry {\n\t\t\t\tdirectories = await getIgnoredDirectories(entry.session.repoPath);\n\t\t\t} catch {\n\t\t\t\tdirectories = undefined;\n\t\t\t}\n\n\t\t\tif (entry.generation === generation) {\n\t\t\t\tif (directories != null) {\n\t\t\t\t\tthis.swapWorkingTreeWatcher(entry, directories);\n\t\t\t\t\tif (entry.filter != null) {\n\t\t\t\t\t\tthis.keptIgnoredDirectories.set(entry.filter, directories);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (unpruned != null) {\n\t\t\t\t\tthis.settleUnprunedDirectories(entry, unpruned, directories);\n\t\t\t\t}\n\t\t\t}\n\t\t} finally {\n\t\t\tentry.reading = false;\n\n\t\t\tif (entry.rereadQueued) {\n\t\t\t\tentry.rereadQueued = false;\n\t\t\t\tif (entry.refreshTimer == null && this.wtWatchers.get(entry.session.repoPath) === entry) {\n\t\t\t\t\tthis.refreshIgnorePruning(entry);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate async refreshDelegatedIgnores(\n\t\tentry: WorkingTreeWatcherEntry,\n\t\tdelegation: GitIgnoreDelegation,\n\t): Promise<void> {\n\t\tconst repoPath = entry.session.repoPath;\n\t\tconst generation = entry.generation;\n\t\tconst initial = !delegation.initialApplied;\n\t\tconst verifyingStartup = !initial && !delegation.verified;\n\t\tconst reason = initial ? 'initial' : verifyingStartup ? 'recovery' : (delegation.pendingRefresh ?? 'worktree');\n\t\tdelegation.pendingRefresh = undefined;\n\t\tdelegation.refreshing = true;\n\n\t\ttry {\n\t\t\tconst record = this.sessionMap.get(repoPath);\n\t\t\tconst inputs =\n\t\t\t\trecord == null\n\t\t\t\t\t? undefined\n\t\t\t\t\t: await this.getGitIgnoreWatchInputs?.(repoPath, record.gitDir, {\n\t\t\t\t\t\t\trefreshConfig: verifyingStartup,\n\t\t\t\t\t\t});\n\t\t\tif (entry.generation !== generation || entry.delegation !== delegation) return;\n\t\t\tif (inputs == null) {\n\t\t\t\tthis.relinquishIgnoreDelegation(entry);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (verifyingStartup) {\n\t\t\t\tawait entry.filter?.refresh();\n\t\t\t\tif (entry.generation !== generation || entry.delegation !== delegation) return;\n\t\t\t}\n\n\t\t\tawait delegation.watcher.refreshGitIgnores(reason, inputs);\n\t\t\tif (entry.delegation !== delegation || this.wtWatchers.get(repoPath) !== entry) return;\n\t\t\tif (initial) {\n\t\t\t\tdelegation.initialApplied = true;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tawait entry.filter?.ready().catch(() => undefined);\n\t\t\tif (entry.generation !== generation || entry.delegation !== delegation) return;\n\n\t\t\tdelegation.verified = true;\n\t\t\tthis.reconcileWorkingTreeLifecycle(entry, entry.reliability, {\n\t\t\t\trescan: !verifyingStartup && !entry.starting,\n\t\t\t});\n\t\t} catch {\n\t\t\tif (this.wtWatchers.get(repoPath) === entry && entry.delegation === delegation) {\n\t\t\t\tthis.relinquishIgnoreDelegation(entry);\n\t\t\t}\n\t\t} finally {\n\t\t\tdelegation.refreshing = false;\n\t\t\tif (\n\t\t\t\tentry.delegation === delegation &&\n\t\t\t\tthis.wtWatchers.get(repoPath) === entry &&\n\t\t\t\tentry.refreshTimer == null &&\n\t\t\t\t(delegation.pendingRefresh != null || (delegation.initialApplied && !delegation.verified))\n\t\t\t) {\n\t\t\t\tthis.refreshIgnorePruning(entry);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate relinquishIgnoreDelegation(entry: WorkingTreeWatcherEntry): void {\n\t\tconst delegation = entry.delegation;\n\t\tif (delegation == null) return;\n\n\t\tentry.delegation = undefined;\n\t\tentry.watcher = undefined;\n\t\tentry.starting = false;\n\t\tentry.awaitingStartAck = false;\n\t\tentry.generation++;\n\t\tclearTimeout(entry.refreshTimer);\n\t\tentry.refreshTimer = undefined;\n\t\tdelegation.watcher.dispose();\n\n\t\tthis.placeFallbackWorkingTreeWatcher(entry, true);\n\t}\n\n\tprivate placeFallbackWorkingTreeWatcher(entry: WorkingTreeWatcherEntry, withdrawing = false): void {\n\t\tlet created: CreatedWorkingTreeWatcher;\n\t\ttry {\n\t\t\tcreated = this.createWorkingTreeWatcher(entry.session.repoPath, entry.onEvent, workingTreeExcludes);\n\t\t} catch {\n\t\t\tthis.reconcileWorkingTreeLifecycle(entry, 'unwatchable', { initial: true, rescan: withdrawing });\n\t\t\treturn;\n\t\t}\n\n\t\tentry.watcher = created.watcher;\n\t\tentry.awaitingStartAck = created.awaitingStartAck;\n\t\tentry.starting = created.awaitingStartAck;\n\t\tthis.reconcileWorkingTreeLifecycle(entry, created.reliability, {\n\t\t\tinitial: true,\n\t\t\trescan: !entry.starting || created.reliability === 'unwatchable',\n\t\t});\n\t\tthis.refreshIgnorePruning(entry);\n\t}\n\n\t/**\n\t * A directory the read left unexcluded is one git won't prune (or the read failed), so it never triggers a read\n\t * again until ignore rules change — otherwise each of its events would spawn git.\n\t */\n\tprivate settleUnprunedDirectories(\n\t\tentry: WorkingTreeWatcherEntry,\n\t\tunpruned: readonly string[],\n\t\tdirectories: readonly string[] | undefined,\n\t): void {\n\t\tfor (const dir of unpruned) {\n\t\t\tentry.unpruned?.delete(dir);\n\t\t\tif (directories?.some(d => d === dir || dir.startsWith(`${d}/`))) continue;\n\n\t\t\tentry.unprunable ??= new Set();\n\t\t\tentry.unprunable.add(dir);\n\t\t}\n\t}\n\n\tprivate swapWorkingTreeWatcher(entry: WorkingTreeWatcherEntry, directories: readonly string[]): void {\n\t\tconst previous = entry.ignoredDirectories;\n\t\tif (previous.length === directories.length && previous.every(d => directories.includes(d))) return;\n\n\t\tlet created: CreatedWorkingTreeWatcher;\n\t\ttry {\n\t\t\tcreated = this.createWorkingTreeWatcher(entry.session.repoPath, entry.onEvent, [\n\t\t\t\t...workingTreeExcludes,\n\t\t\t\t...directories,\n\t\t\t]);\n\t\t} catch {\n\t\t\treturn;\n\t\t}\n\n\t\tconst previousWatcher = entry.watcher;\n\t\tentry.watcher = created.watcher;\n\t\tentry.awaitingStartAck = created.awaitingStartAck;\n\t\tentry.starting = created.awaitingStartAck;\n\t\tentry.ignoredDirectories = directories;\n\t\tpreviousWatcher?.dispose();\n\t\tthis.reconcileWorkingTreeLifecycle(entry, created.reliability, {\n\t\t\trescan: previous.some(d => !directories.some(n => n === d || d.startsWith(`${n}/`))),\n\t\t});\n\t}\n\n\tprivate refreshWorkingTreeFilter(repoPath: string, reason: 'metadata' | 'recovery' = 'metadata'): void {\n\t\tconst entry = this.wtWatchers.get(repoPath);\n\t\tif (entry == null) return;\n\n\t\tif (entry.filter != null) {\n\t\t\tvoid entry.filter.refresh();\n\t\t}\n\t\tthis.scheduleIgnorePruningRefresh(entry, reason);\n\t}\n\n\tprivate disposeSessionRecord(record: SessionRecord): void {\n\t\t// The working tree first: with it still up, leaving the group would read as a move back to `'events'` and\n\t\t// announce one for a repository that is going away\n\t\tthis.stopWorkingTreeWatcher(record.session.repoPath);\n\t\tthis.disconnectFromWatchGroup(record);\n\t\tthis.updateWatchMode(record);\n\t\trecord.session.dispose();\n\t}\n}\n\nfunction filterWorkingTreePaths(absolutePaths: string[], repoPath: string, filter: GitIgnoreFilter): string[] {\n\tconst result: string[] = [];\n\tfor (const p of absolutePaths) {\n\t\tif (!isDescendant(p, repoPath)) continue;\n\n\t\tconst relativePath = relative(repoPath, p);\n\t\tif (!filter.isIgnored(relativePath)) {\n\t\t\tresult.push(p);\n\t\t}\n\t}\n\treturn result;\n}\n"],"mappings":";;;;;;;;;;;;;AA+BA,MAAM,8BAA8B;AAEpC,MAAM,8BAA8B;;;;;;;;;;;;AAwLpC,IAAa,yBAAb,MAAiE;CAChE,yBAA0C,IAAI,QAAgC;;CAE9E,IAAI,wBAAuD;EAC1D,OAAO,KAAK,uBAAuB;CACpC;CAEA,0BAA2C,IAAI,QAAgB;;;CAG/D,IAAI,yBAAwC;EAC3C,OAAO,KAAK,wBAAwB;CACrC;CAEA,wBAAyC,IAAI,QAAgB;;;;;;CAM7D,IAAI,uBAAsC;EACzC,OAAO,KAAK,sBAAsB;CACnC;CAEA,wBAAyC,IAAI,QAAuD;;;;;;CAMpG,IAAI,uBAA6E;EAChF,OAAO,KAAK,sBAAsB;CACnC;CAEA,0BAA2C,IAAI,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MAAK,YAAY,SAAS,CAAC,CAAC,GAAG;EAE5F,IAAI;EACJ,IAAI;GACH,UAAU,KAAK,yBAAyB,MAAM,QAAQ,UAAU,MAAM,SAAS,CAC9E,GAAG,qBACH,GAAG,WACJ,CAAC;EACF,QAAQ;GACP;EACD;EAEA,MAAM,kBAAkB,MAAM;EAC9B,MAAM,UAAU,QAAQ;EACxB,MAAM,mBAAmB,QAAQ;EACjC,MAAM,WAAW,QAAQ;EACzB,MAAM,qBAAqB;EAC3B,iBAAiB,QAAQ;EACzB,KAAK,8BAA8B,OAAO,QAAQ,aAAa,EAC9D,QAAQ,SAAS,MAAK,MAAK,CAAC,YAAY,MAAK,MAAK,MAAM,KAAK,EAAE,WAAW,GAAG,EAAE,EAAE,CAAC,CAAC,EACpF,CAAC;CACF;CAEA,yBAAiC,UAAkB,SAAkC,YAAkB;EACtG,MAAM,QAAQ,KAAK,WAAW,IAAI,QAAQ;EAC1C,IAAI,SAAS,MAAM;EAEnB,IAAI,MAAM,UAAU,MACnB,MAAW,OAAO,QAAQ;EAE3B,KAAK,6BAA6B,OAAO,MAAM;CAChD;CAEA,qBAA6B,QAA6B;EAGzD,KAAK,uBAAuB,OAAO,QAAQ,QAAQ;EACnD,KAAK,yBAAyB,MAAM;EACpC,KAAK,gBAAgB,MAAM;EAC3B,OAAO,QAAQ,QAAQ;CACxB;AACD;AAEA,SAAS,uBAAuB,eAAyB,UAAkB,QAAmC;CAC7G,MAAM,SAAmB,CAAC;CAC1B,KAAK,MAAM,KAAK,eAAe;EAC9B,IAAI,CAAC,aAAa,GAAG,QAAQ,GAAG;EAEhC,MAAM,eAAe,SAAS,UAAU,CAAC;EACzC,IAAI,CAAC,OAAO,UAAU,YAAY,GACjC,OAAO,KAAK,CAAC;CAEf;CACA,OAAO;AACR"}
|
|
1
|
+
{"version":3,"file":"watchService.js","names":[],"sources":["../../../../git/src/watching/watchService.ts"],"sourcesContent":["import type { UnifiedDisposable } from '@gitlens/utils/disposable.js';\nimport type { Event } from '@gitlens/utils/event.js';\nimport { Emitter } from '@gitlens/utils/event.js';\nimport { isDescendant, relative } from '@gitlens/utils/path.js';\nimport { isLinux, isWindows } from '@gitlens/utils/platform.js';\nimport type { ResourceUsage } from '@gitlens/utils/resourceUsage.js';\nimport { getRepositoryKey } from '@gitlens/utils/uri.js';\nimport type { GitDir, RepositoryChange } from '../models/repository.js';\nimport type { WatcherRepoChangeEvent } from './changeEvent.js';\nimport type { PollTarget } from './gitDirPoller.js';\nimport { GitDirPoller } from './gitDirPoller.js';\nimport type { GitIgnoreFilter } from './gitIgnoreFilter.js';\nimport type {\n\tFileWatcher,\n\tFileWatcherOptions,\n\tFileWatcherReliability,\n\tFileWatchEvent,\n\tFileWatchingProvider,\n\tGitIgnoreRefreshReason,\n\tGitIgnoreWatchInputs,\n\tGitIgnoringFileWatcher,\n} from './provider.js';\nimport { createWorkingTreeNoiseFilter, workingTreeExcludes } from './watcherPatterns.js';\nimport type { WatchGroupHooks } from './watchGroup.js';\nimport { WatchGroup } from './watchGroup.js';\nimport { RepositoryWatchSession } from './watchSession.js';\n\n/**\n * Cap on paths held while the gitignore filter loads. Higher than the session's own cap because these are\n * pre-filter — most of a build's output is typically gitignored and would be discarded on replay, so a\n * tighter bound here would mark batches incomplete when they filter down to almost nothing.\n */\nconst maxBufferedWorkingTreePaths = 5000;\n\nconst maxIgnoreCheckPaths = 1000;\nconst ignoreCheckDelayMs = 100;\n\ntype IgnorePathChecker = (paths: readonly string[], cancellation: AbortSignal) => Promise<ReadonlySet<string>>;\n\ninterface IgnoreCheckBatch {\n\treadonly check: IgnorePathChecker;\n\tpaths: Map<string, { relativePath: string; deleted: boolean }>;\n\ttimer?: ReturnType<typeof setTimeout>;\n\tcontroller?: AbortController;\n\tincomplete: boolean;\n}\n\nconst ignorePruningRefreshDelayMs = 500;\n\ninterface GitIgnoreDelegation {\n\treadonly watcher: GitIgnoringFileWatcher;\n\tinitialApplied: boolean;\n\trefreshing: boolean;\n\tverified: boolean;\n\tpendingRefresh?: Exclude<GitIgnoreRefreshReason, 'initial'>;\n}\n\ninterface CreatedWorkingTreeWatcher {\n\treadonly watcher: FileWatcher;\n\treadonly reliability: FileWatcherReliability;\n\treadonly awaitingStartAck: boolean;\n\treadonly delegation?: GitIgnoreDelegation;\n}\n\ninterface WorkingTreeWatcherEntry {\n\treadonly session: RepositoryWatchSession;\n\t/** The event handler shared by every watcher this entry has had — a re-created watcher reuses it */\n\treadonly onEvent: (event: FileWatchEvent) => void;\n\treadonly ignoreCheck?: IgnoreCheckBatch;\n\treadonly filter?: GitIgnoreFilter;\n\twatcher: FileWatcher | undefined;\n\tdelegation?: GitIgnoreDelegation;\n\t/** The git-ignored directories the live watcher was created excluding (on top of the static set) */\n\tignoredDirectories: readonly string[];\n\t/** Bumped by every ignore-rule change and by stopping; a read that lands under a different value is stale */\n\tgeneration: number;\n\treading: boolean;\n\t/** A refresh came due while a read was in flight */\n\trereadQueued: boolean;\n\trefreshTimer?: ReturnType<typeof setTimeout>;\n\t/** What the live watcher last reported; a re-created watcher starts over from its own report */\n\treliability: FileWatcherReliability;\n\tstarting: boolean;\n\tawaitingStartAck: boolean;\n\t/** Compares the host's working-tree fingerprint while the watcher isn't `reliable` */\n\tpollTarget?: PollTarget;\n\t/**\n\t * Git-ignored directories (repo-relative) whose events reached the post-filter, so the watcher isn't pruning them —\n\t * typically created after the last read (a first build's `dist/`). Each waits for a read that started after it.\n\t */\n\tunpruned?: Set<string>;\n\t/**\n\t * Directories a read showed git won't prune (they hold tracked files, or glob metacharacters in their names);\n\t * cleared when ignore rules change\n\t */\n\tunprunable?: Set<string>;\n}\n\n/**\n * A host whose watchers can report they can't be trusted (see `FileWatcherOptions.onDidChangeReliability`) passes\n * these to have core poll in their place. A `.git` directory is polled by statting the files its watchers read and\n * feeding each one that moved through the same interpretation as a watcher event; a working tree is never walked.\n */\nexport interface WatchPollingOptions {\n\t/**\n\t * Reads a path's modification time (ms) and size; `undefined` when it doesn't exist. A rejection means unknown:\n\t * the last reading stands, so it never counts as a change.\n\t */\n\treadonly stat: (path: string) => Promise<{ readonly mtime: number; readonly size: number } | undefined>;\n\t/** Whether a poll is worth running now. Default: the service isn't suspended (`suspendAll`/`resumeAll`) */\n\treadonly isActive?: () => boolean;\n\t/** How often each untrusted watcher is polled. Default: 60000ms */\n\treadonly intervalMs?: number;\n\t/**\n\t * How often `isActive` is looked at, which bounds how late the first poll after it turns true can be. Only with\n\t * `isActive`: the default gate wakes only for a poll. Default: 5000ms\n\t */\n\treadonly activeCheckMs?: number;\n\t/**\n\t * Refs to poll for a repository beyond its subscribers' `relevantRefs`: one with none (a host listing every branch)\n\t * still needs its checked-out branch's upstream, which a push moves without writing `FETCH_HEAD`\n\t */\n\treadonly getRefs?: (repoPath: string) => Iterable<string>;\n\t/**\n\t * Something that changes whenever the repository's working tree does (e.g. a digest of its status and the\n\t * changed files' stats), compared at each poll while working-tree subscribers are watching a working tree whose\n\t * watcher can't be trusted; a change is reported with no paths. `undefined` or a rejection skips that poll. With or\n\t * without it, a working tree whose watcher is `unwatchable` is reported changed (no paths) whenever its index or\n\t * `HEAD` changes.\n\t */\n\treadonly getWorkingTreeFingerprint?: (repoPath: string) => Promise<string | undefined>;\n}\n\nexport interface WatchServiceOptions {\n\treadonly watchingProvider: FileWatchingProvider;\n\t/** Default debounce for repo changes when subscriber doesn't specify. Default: 250ms */\n\treadonly defaultRepoDelayMs?: number;\n\t/** Default debounce for working tree changes when subscriber doesn't specify. Default: 2500ms */\n\treadonly defaultWorkingTreeDelayMs?: number;\n\t/** Default cap on how long continuous repo activity can defer a flush. `Infinity` disables it. Default: 2000ms */\n\treadonly defaultRepoMaxWaitMs?: number;\n\t/** Default cap on how long continuous working tree activity can defer a flush. `Infinity` disables it. Default: 10000ms */\n\treadonly defaultWorkingTreeMaxWaitMs?: number;\n\t/** Returns a GitIgnoreFilter for a given repo. When absent or returns undefined, gitignore filtering is skipped. */\n\treadonly getIgnoreFilter?: (repoPath: string, gitDirPath: string) => GitIgnoreFilter | undefined;\n\t/**\n\t * Confirms rule matches against the checkout's current Git index when processing a batch of events.\n\t * A provider can prune ahead of the checker when it preserves indexed paths under live metadata coverage.\n\t */\n\treadonly getIgnorePathChecker?: (repoPath: string) => IgnorePathChecker | undefined;\n\t/**\n\t * Returns repo-relative ignored directories for legacy native exclude pruning (`supportsExcludes`).\n\t * A rejection keeps the existing excludes.\n\t */\n\treadonly getIgnoredDirectories?: (repoPath: string) => Promise<readonly string[]>;\n\t/** Inputs for a provider-managed watch. Undefined or a rejection selects ordinary watching. */\n\treadonly getGitIgnoreWatchInputs?: (\n\t\trepoPath: string,\n\t\tgitDir: GitDir,\n\t\toptions?: { refreshConfig?: boolean },\n\t) => Promise<GitIgnoreWatchInputs | undefined>;\n\t/**\n\t * Returns the absolute, normalized folders whose worktrees are ignored (see `GitProvider.getIgnoredWorktreeRoots`):\n\t * with a `readFile` and a `readDirectory`, the watcher's reports of their admin entries reach no session. Asked\n\t * once per common git dir, when its first session starts watching, and never without both. When absent, empty or\n\t * rejected, no admin entry is read.\n\t */\n\treadonly getIgnoredWorktreeRoots?: (repoPath: string) => Promise<readonly string[]>;\n\t/**\n\t * Returns the folders whose worktrees are ignored, relative to a repository's common git dir (see\n\t * `GitProvider.getIgnoredWorktreeFolders`): the `.git` watchers whose tree holds the common git dir leave\n\t * them unwatched. Asked once per common git dir, when its first session starts watching.\n\t */\n\treadonly getIgnoredWorktreeFolders?: (repoPath: string) => readonly string[];\n\t/** Opts into polling the watchers that report they can't be trusted. Metadata coverage for tracked-path protection is independent of polling. */\n\treadonly polling?: WatchPollingOptions;\n\t/**\n\t * Reads a file's bytes; a rejection means it couldn't be read. With it, each report of a repository's shared\n\t * `.git/config` is classified by what changed in the file: a change confined to some branches' `branch.<name>`\n\t * sections reaches only the subscribers following those branches, and carries no `remotes`. Without it, every\n\t * config change concerns everyone, as before.\n\t */\n\treadonly readFile?: (path: string) => Promise<Uint8Array>;\n\t/**\n\t * Returns a directory's entries with their types, as the host file system's `readDirectory` does; only the\n\t * directories count as admin entries (a stray `.DS_Store` is no worktree's). A rejection means it couldn't be\n\t * listed, and one whose `code` is `ENOENT` or `FileNotFound` that the directory isn't there. With it and a\n\t * `readFile`, the admin entries of a repository's worktrees are listed and read once as its first session starts\n\t * watching, so the reports of an ignored worktree's (see `getIgnoredWorktreeRoots`) reach no session, and the others\n\t * aren't held back.\n\t */\n\treadonly readDirectory?: (path: string) => Promise<readonly (readonly [string, number])[]>;\n}\n\nexport interface WatchHooks {\n\t/** Called when FETCH_HEAD changed (for last-fetched tracking) */\n\treadonly onFetchHeadChanged?: (repoPath: string) => void;\n\t/** Called when .git/info/exclude changed */\n\treadonly onIgnoresChanged?: (repoPath: string) => void;\n\t/** Called when .gitignore changed in the working tree (extension watches this separately) */\n\treadonly onGitIgnoreChanged?: (repoPath: string) => void;\n}\n\nexport interface WatchHandle {\n\treadonly session: RepositoryWatchSession;\n\tdispose(): void;\n}\n\ninterface SessionRecord {\n\treadonly session: RepositoryWatchSession;\n\treadonly gitDir: GitDir;\n\t/**\n\t * Hooks contributed by all current `watch()` callers for this repo path. Earlier\n\t * implementations stored just the first caller's hooks (`WatchHooks | undefined`) and\n\t * silently dropped subsequent callers' hooks — that broke the case where a low-level\n\t * subscriber (e.g. the Graph's secondary-worktree WIP watcher) opened the session\n\t * first without hooks, and a later `Repository.watch()` for the same path lost\n\t * its `markFetched` / `onIgnoresChanged` wiring. Each `watch()` call adds its hooks\n\t * to this set and removes them on dispose; fire sites iterate the set.\n\t */\n\treadonly watchHooks: Set<WatchHooks>;\n\trefCount: number;\n\t/** The mode {@link RepositoryWatchService.onDidChangeWatchMode} last announced; `'events'` while unwatched */\n\twatchMode: 'events' | 'poll';\n}\n\n/**\n * Global service that multiplexes repository watching across all repos.\n *\n * Manages:\n * - Session map: one `RepositoryWatchSession` per repo path (ref-counted)\n * - Watch groups: shared `.git` watchers across worktrees\n * - Working tree watchers: per-repo filesystem watchers with gitignore filtering\n *\n * Sessions and watch groups are created lazily on first `subscribe()`\n * within a session, and destroyed when the last subscriber leaves.\n */\nexport class RepositoryWatchService implements UnifiedDisposable {\n\tprivate readonly _onDidChangeRepository = new Emitter<WatcherRepoChangeEvent>();\n\t/** Global multiplexed event for ALL watched repos */\n\tget onDidChangeRepository(): Event<WatcherRepoChangeEvent> {\n\t\treturn this._onDidChangeRepository.event;\n\t}\n\n\tprivate readonly _onDidChangeWorkingTree = new Emitter<string>();\n\t/** Global multiplexed working-tree change event (repo path) for ALL watched repos. Fires once per\n\t * debounced flush per session — the single point that drives the cache's status clock for working-tree edits. */\n\tget onDidChangeWorkingTree(): Event<string> {\n\t\treturn this._onDidChangeWorkingTree.event;\n\t}\n\n\tprivate readonly _onDidChangeFetchHead = new Emitter<string>();\n\t/**\n\t * Global FETCH_HEAD change event (repo path) for ALL watched repos, fired as each change is seen (no debounce).\n\t * FETCH_HEAD maps to no {@link RepositoryChange} on the session, so this is how a host invalidates its cached\n\t * last-fetched time — the standalone service bridges it to the cache's `lastFetched`.\n\t */\n\tget onDidChangeFetchHead(): Event<string> {\n\t\treturn this._onDidChangeFetchHead.event;\n\t}\n\n\tprivate readonly _onDidChangeWatchMode = new Emitter<{ repoPath: string; mode: 'events' | 'poll' }>();\n\t/**\n\t * Fires as a watched repository starts being polled in place of a watcher (see {@link getWatchMode}), and with\n\t * `'events'` as it is watched natively again. Never fires as the repository stops being watched; one watched again\n\t * later starts from `'events'`.\n\t */\n\tget onDidChangeWatchMode(): Event<{ repoPath: string; mode: 'events' | 'poll' }> {\n\t\treturn this._onDidChangeWatchMode.event;\n\t}\n\n\tprivate readonly _onDidChangeRepoWatched = new Emitter<{ repoPath: string; watched: boolean }>();\n\t/**\n\t * Fires as a repository's `.git` directory starts being watched (its session's first repo subscriber connected it\n\t * to its watch group) and as it stops (its last one left, or its session was disposed); see {@link isRepoWatched}.\n\t * `repoPath` is the session's key ({@link getRepositoryKey}). Never fires as the service itself is disposed, nor as\n\t * the session suspends or resumes: a suspended session still reports what it held once it resumes, so there is\n\t * nothing to hand off, and {@link isRepoWatched} answers `false` meanwhile without announcing it.\n\t */\n\tget onDidChangeRepoWatched(): Event<{ repoPath: string; watched: boolean }> {\n\t\treturn this._onDidChangeRepoWatched.event;\n\t}\n\n\tprivate readonly defaultRepoDelayMs?: number;\n\tprivate readonly defaultWorkingTreeDelayMs?: number;\n\tprivate readonly defaultRepoMaxWaitMs?: number;\n\tprivate readonly defaultWorkingTreeMaxWaitMs?: number;\n\tprivate readonly getIgnoreFilter?: (repoPath: string, gitDirPath: string) => GitIgnoreFilter | undefined;\n\tprivate readonly getIgnorePathChecker?: WatchServiceOptions['getIgnorePathChecker'];\n\tprivate readonly getIgnoredDirectories?: (repoPath: string) => Promise<readonly string[]>;\n\tprivate readonly getGitIgnoreWatchInputs?: WatchServiceOptions['getGitIgnoreWatchInputs'];\n\tprivate readonly getIgnoredWorktreeRoots?: (repoPath: string) => Promise<readonly string[]>;\n\tprivate readonly getIgnoredWorktreeFolders?: (repoPath: string) => readonly string[];\n\tprivate readonly provider: FileWatchingProvider;\n\tprivate readonly trackedPruning: boolean;\n\tprivate readonly poller: GitDirPoller | undefined;\n\tprivate readonly readFile: ((path: string) => Promise<Uint8Array>) | undefined;\n\tprivate readonly readDirectory: ((path: string) => Promise<readonly (readonly [string, number])[]>) | undefined;\n\n\tprivate readonly sessionMap = new Map<string, SessionRecord>();\n\tprivate readonly watchGroups = new Map<string, WatchGroup>();\n\tprivate readonly wtWatchers = new Map<string, WorkingTreeWatcherEntry>();\n\t/**\n\t * The last git-ignored directory read under each filter's current rules, kept across a working-tree watcher's\n\t * stop and start so a restart can skip the read; dropped with the filter\n\t */\n\tprivate readonly keptIgnoredDirectories = new WeakMap<GitIgnoreFilter, readonly string[]>();\n\tprivate _disposed = false;\n\t/** Global suspend state (driven by window focus); inherited by sessions created via {@link watch}. */\n\tprivate _suspended = false;\n\n\tconstructor(options: WatchServiceOptions) {\n\t\tthis.provider = options.watchingProvider;\n\t\tthis.trackedPruning = this.provider.supportsTrackedGitIgnorePaths === true;\n\t\tthis.defaultRepoDelayMs = options.defaultRepoDelayMs;\n\t\tthis.defaultWorkingTreeDelayMs = options.defaultWorkingTreeDelayMs;\n\t\tthis.defaultRepoMaxWaitMs = options.defaultRepoMaxWaitMs;\n\t\tthis.defaultWorkingTreeMaxWaitMs = options.defaultWorkingTreeMaxWaitMs;\n\t\tthis.getIgnoreFilter = options.getIgnoreFilter;\n\t\tthis.getIgnorePathChecker = options.getIgnorePathChecker;\n\t\tthis.getIgnoredDirectories = options.getIgnoredDirectories;\n\t\tthis.getGitIgnoreWatchInputs = options.getGitIgnoreWatchInputs;\n\t\tthis.getIgnoredWorktreeRoots = options.getIgnoredWorktreeRoots;\n\t\tthis.getIgnoredWorktreeFolders = options.getIgnoredWorktreeFolders;\n\t\tthis.readFile = options.readFile;\n\t\tthis.readDirectory = options.readDirectory;\n\t\tif (options.polling != null) {\n\t\t\tthis.poller = new GitDirPoller(options.polling);\n\t\t}\n\t}\n\n\t[Symbol.dispose](): void {\n\t\tthis.dispose();\n\t}\n\n\tdispose(): void {\n\t\tif (this._disposed) return;\n\n\t\tthis._disposed = true;\n\n\t\tfor (const record of this.sessionMap.values()) {\n\t\t\tthis.disposeSessionRecord(record);\n\t\t}\n\t\tthis.sessionMap.clear();\n\n\t\tfor (const group of this.watchGroups.values()) {\n\t\t\tgroup.dispose();\n\t\t}\n\t\tthis.watchGroups.clear();\n\n\t\tfor (const repoPath of [...this.wtWatchers.keys()]) {\n\t\t\tthis.stopWorkingTreeWatcher(repoPath);\n\t\t}\n\n\t\tthis.poller?.dispose();\n\n\t\tthis._onDidChangeRepository.dispose();\n\t\tthis._onDidChangeWorkingTree.dispose();\n\t\tthis._onDidChangeFetchHead.dispose();\n\t\tthis._onDidChangeWatchMode.dispose();\n\t\tthis._onDidChangeRepoWatched.dispose();\n\t}\n\n\t/**\n\t * Start watching a repository. Reference-counted:\n\t * same repoPath → same session (refCount++).\n\t * Worktrees sharing a .git dir share the WatchGroup.\n\t *\n\t * Returns a handle with the session and a dispose function.\n\t * Disposing the handle decrements the ref count.\n\t *\n\t * `repoPath` is keyed by {@link getRepositoryKey}, and every session, event and hook carries that key — the\n\t * same one the cache fences status reads on — so a host passing `C:\\repo\\` and one passing `c:/repo` share\n\t * a session and advance the same status clock.\n\t */\n\twatch(repoPath: string, gitDir: GitDir, watchHooks?: WatchHooks): WatchHandle | undefined {\n\t\tif (this._disposed) return undefined;\n\n\t\trepoPath = getRepositoryKey(repoPath);\n\n\t\tlet record = this.sessionMap.get(repoPath);\n\t\tif (record != null) {\n\t\t\trecord.refCount++;\n\t\t\tif (watchHooks != null) {\n\t\t\t\trecord.watchHooks.add(watchHooks);\n\t\t\t}\n\t\t} else {\n\t\t\tconst session = new RepositoryWatchSession({\n\t\t\t\trepoPath: repoPath,\n\t\t\t\tdefaultRepoDelayMs: this.defaultRepoDelayMs,\n\t\t\t\tdefaultWorkingTreeDelayMs: this.defaultWorkingTreeDelayMs,\n\t\t\t\tdefaultRepoMaxWaitMs: this.defaultRepoMaxWaitMs,\n\t\t\t\tdefaultWorkingTreeMaxWaitMs: this.defaultWorkingTreeMaxWaitMs,\n\t\t\t\tsuspended: this._suspended,\n\t\t\t\tlifecycle: {\n\t\t\t\t\tonFirstRepoSubscriber: (): void => {\n\t\t\t\t\t\tconst rec = this.sessionMap.get(repoPath);\n\t\t\t\t\t\tif (rec != null) {\n\t\t\t\t\t\t\tthis.connectToWatchGroup(rec);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tonLastRepoSubscriber: (): void => {\n\t\t\t\t\t\tconst rec = this.sessionMap.get(repoPath);\n\t\t\t\t\t\tif (rec != null) {\n\t\t\t\t\t\t\tconst entry = this.wtWatchers.get(repoPath);\n\t\t\t\t\t\t\tif (entry?.delegation != null) {\n\t\t\t\t\t\t\t\tthis.relinquishIgnoreDelegation(entry);\n\t\t\t\t\t\t\t}\n\t\t\t\t\t\t\tthis.disconnectFromWatchGroup(rec);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tonFirstWorkingTreeSubscriber: (): void => {\n\t\t\t\t\t\tconst rec = this.sessionMap.get(repoPath);\n\t\t\t\t\t\tif (rec != null) {\n\t\t\t\t\t\t\tthis.startWorkingTreeWatcher(rec);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t\tonLastWorkingTreeSubscriber: (): void => {\n\t\t\t\t\t\tthis.stopWorkingTreeWatcher(repoPath);\n\t\t\t\t\t\tconst rec = this.sessionMap.get(repoPath);\n\t\t\t\t\t\tif (rec != null) {\n\t\t\t\t\t\t\tthis.updateWatchMode(rec);\n\t\t\t\t\t\t}\n\t\t\t\t\t},\n\t\t\t\t},\n\t\t\t\tonDidFireRepoChange: (event): void => {\n\t\t\t\t\tthis._onDidChangeRepository.fire(event);\n\t\t\t\t\tconst entry = this.wtWatchers.get(repoPath);\n\t\t\t\t\tif (entry?.delegation == null || this.trackedPruning) return;\n\n\t\t\t\t\tif (\n\t\t\t\t\t\tevent.changes.has('index') ||\n\t\t\t\t\t\tevent.changes.has('head') ||\n\t\t\t\t\t\t(event.changes.has('config') && !event.configConfined)\n\t\t\t\t\t) {\n\t\t\t\t\t\tthis.refreshWorkingTreeFilter(repoPath);\n\t\t\t\t\t}\n\t\t\t\t},\n\t\t\t\tonDidFireWorkingTreeChange: (repoPath): void => {\n\t\t\t\t\tthis._onDidChangeWorkingTree.fire(repoPath);\n\t\t\t\t},\n\t\t\t});\n\n\t\t\tconst watchHooksSet = new Set<WatchHooks>();\n\t\t\tif (watchHooks != null) {\n\t\t\t\twatchHooksSet.add(watchHooks);\n\t\t\t}\n\n\t\t\trecord = {\n\t\t\t\tsession: session,\n\t\t\t\tgitDir: gitDir,\n\t\t\t\twatchHooks: watchHooksSet,\n\t\t\t\trefCount: 1,\n\t\t\t\twatchMode: 'events',\n\t\t\t};\n\t\t\tthis.sessionMap.set(repoPath, record);\n\t\t}\n\n\t\tconst sessionRef = record.session;\n\t\tlet handleDisposed = false;\n\n\t\treturn {\n\t\t\tsession: sessionRef,\n\t\t\tdispose: (): void => {\n\t\t\t\tif (handleDisposed) return;\n\n\t\t\t\thandleDisposed = true;\n\n\t\t\t\tconst rec = this.sessionMap.get(repoPath);\n\t\t\t\tif (rec == null) return;\n\n\t\t\t\trec.refCount--;\n\t\t\t\tif (watchHooks != null) {\n\t\t\t\t\trec.watchHooks.delete(watchHooks);\n\t\t\t\t}\n\t\t\t\tif (rec.refCount <= 0) {\n\t\t\t\t\tthis.sessionMap.delete(repoPath);\n\t\t\t\t\tthis.disposeSessionRecord(rec);\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t}\n\n\t/**\n\t * Core announced one of its own writes for `repoPath`; the session watching it fires the announcement in place of\n\t * the write's own `.git` events (see {@link RepositoryWatchSession.noteSelfWrite}); `refs` are the full ref names it\n\t * moved, when it knows them, and `options.configConfinedToRefs` confines its `config` change to the sections of the\n\t * local branches among them (see `GitServiceHooks.repository.onChanged`); `options.movedWorktrees` confines its\n\t * `worktreeHead` change to those linked worktrees (see `AnnouncedRepositoryChanges.movedWorktrees`). A path no session\n\t * watches is ignored.\n\t */\n\tnoteSelfWrite(\n\t\trepoPath: string,\n\t\tchanges: readonly RepositoryChange[],\n\t\trefs?: readonly string[],\n\t\toptions?: { readonly configConfinedToRefs?: boolean; readonly movedWorktrees?: readonly string[] },\n\t): void {\n\t\tif (this._disposed) return;\n\n\t\tconst key = getRepositoryKey(repoPath);\n\t\tconst entry = this.wtWatchers.get(key);\n\t\tif (\n\t\t\tentry != null &&\n\t\t\t(entry.ignoreCheck != null || this.trackedPruning) &&\n\t\t\t(changes.length === 0 ||\n\t\t\t\tchanges.some(\n\t\t\t\t\tchange =>\n\t\t\t\t\t\tchange === 'index' ||\n\t\t\t\t\t\tchange === 'head' ||\n\t\t\t\t\t\tchange === 'config' ||\n\t\t\t\t\t\tchange === 'ignores' ||\n\t\t\t\t\t\tchange === 'unknown',\n\t\t\t\t))\n\t\t) {\n\t\t\tif (entry.delegation != null) {\n\t\t\t\tthis.refreshWorkingTreeFilter(key);\n\t\t\t} else {\n\t\t\t\tthis.invalidateIgnoreCheck(entry);\n\t\t\t}\n\t\t}\n\t\tthis.sessionMap.get(key)?.session.noteSelfWrite(changes, refs, options);\n\t}\n\n\t/**\n\t * Whether `repoPath`'s `.git` directory is watched: its session has a repo subscriber, so it is connected to its\n\t * watch group (natively, or polled in place of a watcher that can't be trusted). A session with only working-tree\n\t * subscribers, or none, doesn't count, nor does a suspended one: it holds what its watcher hears until it resumes,\n\t * and the poller doesn't poll meanwhile, so a read is served stale. Suspending or resuming announces nothing (see\n\t * {@link onDidChangeRepoWatched}).\n\t */\n\tisRepoWatched(repoPath: string): boolean {\n\t\tconst record = this.sessionMap.get(getRepositoryKey(repoPath));\n\t\treturn record != null && this.isConnected(record) && !record.session.suspended;\n\t}\n\n\t/** Get an existing session by repo path */\n\tgetSession(repoPath: string): RepositoryWatchSession | undefined {\n\t\treturn this.sessionMap.get(getRepositoryKey(repoPath))?.session;\n\t}\n\n\t/**\n\t * Whether the working tree's watch has yet to go live, owing a rescan once it does (see\n\t * `FileWatchingProvider.callsOnDidStart`). Not while it's `unwatchable`: it rescans when it comes back.\n\t */\n\tisWorkingTreeStarting(repoPath: string): boolean {\n\t\tconst entry = this.wtWatchers.get(getRepositoryKey(repoPath));\n\t\treturn entry?.starting === true && entry.reliability !== 'unwatchable';\n\t}\n\n\t/**\n\t * `'poll'` while a watcher the repository is watched through — its `.git` watchers or its working tree's — can't\n\t * watch, and is polled instead; `'events'` while it is watched natively (polled beside an `unreliable` watcher\n\t * included); `undefined` when nothing watches it, which {@link onDidChangeWatchMode} doesn't announce.\n\t */\n\tgetWatchMode(repoPath: string): 'events' | 'poll' | undefined {\n\t\tconst record = this.sessionMap.get(getRepositoryKey(repoPath));\n\t\treturn record != null ? this.computeWatchMode(record) : undefined;\n\t}\n\n\t/** Resource usage retained by repository watchers. */\n\tgetResourceUsage(): ResourceUsage {\n\t\tconst usage: ResourceUsage = {\n\t\t\t'watch.sessions.count': this.sessionMap.size,\n\t\t\t'watch.groups.count': this.watchGroups.size,\n\t\t\t'watch.workingTreeWatchers.count': this.wtWatchers.size,\n\t\t};\n\t\tif (this.poller != null) {\n\t\t\tusage['watch.pollTargets.count'] = this.poller.size;\n\t\t}\n\t\treturn usage;\n\t}\n\n\t/** Suspend all sessions and mark the service suspended so late-joining sessions start suspended */\n\tsuspendAll(): void {\n\t\tthis._suspended = true;\n\t\tfor (const record of this.sessionMap.values()) {\n\t\t\trecord.session.suspend();\n\t\t}\n\t\tfor (const entry of this.wtWatchers.values()) {\n\t\t\tthis.invalidateIgnoreCheck(entry);\n\t\t}\n\t\tthis.poller?.suspend();\n\t}\n\n\t/** Resume all sessions (clearing the global suspend state), with optional per-session delay */\n\tresumeAll(getDelay?: (session: RepositoryWatchSession) => number): void {\n\t\tthis._suspended = false;\n\t\tfor (const record of this.sessionMap.values()) {\n\t\t\tconst delayMs = getDelay?.(record.session);\n\t\t\trecord.session.resume(delayMs);\n\t\t\tconst entry = this.wtWatchers.get(record.session.repoPath);\n\t\t\tif (entry == null) continue;\n\n\t\t\tif (this.poller == null && entry.watcher == null) {\n\t\t\t\tthis.placeFallbackWorkingTreeWatcher(entry);\n\t\t\t}\n\t\t\tif (entry.ignoreCheck != null) {\n\t\t\t\tthis.scheduleIgnoreCheck(entry, entry.ignoreCheck);\n\t\t\t}\n\t\t}\n\t\tthis.poller?.resume();\n\t}\n\n\tprivate getOrCreateWatchGroup(commonGitDir: string, repoPath: string): WatchGroup {\n\t\tlet group = this.watchGroups.get(commonGitDir);\n\t\tif (group == null) {\n\t\t\tgroup = new WatchGroup(\n\t\t\t\tcommonGitDir,\n\t\t\t\tthis.provider,\n\t\t\t\tthis.poller,\n\t\t\t\tthis.readFile,\n\t\t\t\tthis.readDirectory,\n\t\t\t\t// Only a group that can read the admin entries waits on the folders; asking otherwise reads for nothing,\n\t\t\t\t// and leaves a rejection unhandled\n\t\t\t\tthis.readFile != null && this.readDirectory != null\n\t\t\t\t\t? this.getIgnoredWorktreeRoots?.(repoPath)\n\t\t\t\t\t: undefined,\n\t\t\t\tthis.getIgnoredWorktreeFolders?.(repoPath),\n\t\t\t);\n\t\t\tthis.watchGroups.set(commonGitDir, group);\n\t\t}\n\t\treturn group;\n\t}\n\n\tprivate maybeDisposeWatchGroup(commonGitDir: string): void {\n\t\tconst group = this.watchGroups.get(commonGitDir);\n\t\tif (group == null) return;\n\n\t\tif (group.sessions.size === 0) {\n\t\t\tgroup.dispose();\n\t\t\tthis.watchGroups.delete(commonGitDir);\n\t\t}\n\t}\n\n\tprivate connectToWatchGroup(record: SessionRecord): void {\n\t\tconst { session, gitDir, watchHooks } = record;\n\t\tconst commonGitDir = (gitDir.commonUri ?? gitDir.uri).fsPath;\n\t\tconst group = this.getOrCreateWatchGroup(commonGitDir, session.repoPath);\n\n\t\tconst hooks: WatchGroupHooks = {\n\t\t\tonRepoChanged: (\n\t\t\t\t_repoPath: string,\n\t\t\t\tchanges: RepositoryChange[],\n\t\t\t\tref?: string | false,\n\t\t\t\toverflow?: boolean,\n\t\t\t\tconfigBranches?: ReadonlySet<string>,\n\t\t\t\tmovedWorktree?: string,\n\t\t\t): void => {\n\t\t\t\tconst entry = this.wtWatchers.get(session.repoPath);\n\t\t\t\tconst indexMayHaveChanged = changes.includes('index') || changes.includes('head');\n\t\t\t\tif (!overflow && entry != null && (indexMayHaveChanged || changes.includes('config'))) {\n\t\t\t\t\tif (\n\t\t\t\t\t\tthis.trackedPruning &&\n\t\t\t\t\t\tentry.delegation != null &&\n\t\t\t\t\t\t(indexMayHaveChanged || configBranches == null)\n\t\t\t\t\t) {\n\t\t\t\t\t\tthis.refreshWorkingTreeFilter(session.repoPath);\n\t\t\t\t\t} else {\n\t\t\t\t\t\tthis.invalidateIgnoreCheck(entry);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (overflow) {\n\t\t\t\t\tsession.pushUnfencedRepoChanges(changes);\n\t\t\t\t} else {\n\t\t\t\t\tsession.pushRepoChanges(changes, ref, configBranches, movedWorktree);\n\t\t\t\t}\n\n\t\t\t\t// A working tree nothing watches is read again whenever the index or HEAD says it may have moved\n\t\t\t\tif (\n\t\t\t\t\tthis.poller != null &&\n\t\t\t\t\t(changes.includes('index') || changes.includes('head')) &&\n\t\t\t\t\tthis.wtWatchers.get(session.repoPath)?.reliability === 'unwatchable'\n\t\t\t\t) {\n\t\t\t\t\tsession.pushWorkingTreeChanges([], true);\n\t\t\t\t}\n\t\t\t},\n\t\t\tonFetchHeadChanged: (repoPath: string): void => {\n\t\t\t\t// Global first, so a host's cache drops its last-fetched time before any hook re-reads it\n\t\t\t\tthis._onDidChangeFetchHead.fire(repoPath);\n\t\t\t\t// Iterate at fire time so callers that joined after the group was wired up\n\t\t\t\t// still receive events (e.g. a `Repository.watch()` whose hooks landed\n\t\t\t\t// after a hookless `GitRepositoryService.watch` registered first).\n\t\t\t\tfor (const h of watchHooks) {\n\t\t\t\t\th.onFetchHeadChanged?.(repoPath);\n\t\t\t\t}\n\t\t\t},\n\t\t\tonIgnoresChanged: (repoPath, overflow): void => {\n\t\t\t\tthis.refreshWorkingTreeFilter(repoPath, overflow ? 'recovery' : 'metadata');\n\t\t\t\tfor (const h of watchHooks) {\n\t\t\t\t\th.onIgnoresChanged?.(repoPath);\n\t\t\t\t}\n\t\t\t},\n\t\t\tgetProbeRefs: (): Iterable<string> => {\n\t\t\t\tconst refs = session.getRelevantRefs();\n\t\t\t\tfor (const ref of this.poller?.options.getRefs?.(session.repoPath) ?? []) {\n\t\t\t\t\trefs.add(ref);\n\t\t\t\t}\n\t\t\t\treturn refs;\n\t\t\t},\n\t\t\tonMetadataCoverageChanged: live => {\n\t\t\t\tconst entry = this.wtWatchers.get(session.repoPath);\n\t\t\t\tif (entry == null || !this.trackedPruning) return;\n\n\t\t\t\tif (!live) {\n\t\t\t\t\tthis.relinquishIgnoreDelegation(entry);\n\t\t\t\t} else if (\n\t\t\t\t\tentry.delegation == null &&\n\t\t\t\t\tthis.provider.createGitIgnoringWatcher != null &&\n\t\t\t\t\tthis.getGitIgnoreWatchInputs != null\n\t\t\t\t) {\n\t\t\t\t\tthis.replaceWithCoveredWatcher(entry);\n\t\t\t\t}\n\t\t\t},\n\t\t\tonUnwatchableChanged: (): void => this.updateWatchMode(record),\n\t\t};\n\n\t\tconst wasConnected = group.sessions.has(session.repoPath);\n\t\tgroup.addSession(session.repoPath, gitDir, hooks);\n\t\tthis.updateWatchMode(record);\n\t\tif (!wasConnected) {\n\t\t\tthis.fireRepoWatchedIfConnected(record, true);\n\t\t}\n\t}\n\n\tprivate disconnectFromWatchGroup(record: SessionRecord): void {\n\t\tconst { session, gitDir } = record;\n\t\tconst commonGitDir = (gitDir.commonUri ?? gitDir.uri).fsPath;\n\t\tconst group = this.watchGroups.get(commonGitDir);\n\t\tif (group == null) return;\n\n\t\tconst wasConnected = group.sessions.has(session.repoPath);\n\t\tgroup.removeSession(session.repoPath);\n\t\tthis.maybeDisposeWatchGroup(commonGitDir);\n\t\tthis.updateWatchMode(record);\n\t\tif (wasConnected) {\n\t\t\tthis.fireRepoWatchedIfConnected(record, false);\n\t\t}\n\t}\n\n\tprivate isConnected(record: SessionRecord): boolean {\n\t\tconst group = this.watchGroups.get((record.gitDir.commonUri ?? record.gitDir.uri).fsPath);\n\t\treturn group?.sessions.has(record.session.repoPath) ?? false;\n\t}\n\n\t/** Announces that `record` was just connected (`watched`) or disconnected, once that is what it is */\n\tprivate fireRepoWatchedIfConnected(record: SessionRecord, watched: boolean): void {\n\t\tif (this._disposed || this.isConnected(record) !== watched) return;\n\n\t\tthis._onDidChangeRepoWatched.fire({ repoPath: record.session.repoPath, watched: watched });\n\t}\n\n\tprivate computeWatchMode(record: SessionRecord): 'events' | 'poll' | undefined {\n\t\tconst repoPath = record.session.repoPath;\n\t\tconst group = this.watchGroups.get((record.gitDir.commonUri ?? record.gitDir.uri).fsPath);\n\t\tconst connected = group?.sessions.has(repoPath) ?? false;\n\t\tconst wt = this.wtWatchers.get(repoPath);\n\t\tif (!connected && wt == null) return undefined;\n\t\tif (this.poller == null && wt?.watcher == null) return connected ? 'events' : undefined;\n\n\t\treturn group?.isUnwatchable(repoPath) || wt?.reliability === 'unwatchable' ? 'poll' : 'events';\n\t}\n\n\tprivate updateWatchMode(record: SessionRecord): void {\n\t\tif (this._disposed) return;\n\n\t\tconst mode = this.computeWatchMode(record);\n\t\tif (mode == null) {\n\t\t\trecord.watchMode = 'events';\n\t\t\treturn;\n\t\t}\n\t\tif (mode === record.watchMode) return;\n\n\t\trecord.watchMode = mode;\n\t\tthis._onDidChangeWatchMode.fire({ repoPath: record.session.repoPath, mode: mode });\n\t}\n\n\tprivate startWorkingTreeWatcher(record: SessionRecord): void {\n\t\tconst { session, gitDir, watchHooks } = record;\n\t\tconst repoPath = session.repoPath;\n\t\tif (this.wtWatchers.has(repoPath)) return;\n\n\t\tconst canPrune = this.canPruneIgnoredDirectories();\n\t\tlet entry: WorkingTreeWatcherEntry | undefined;\n\n\t\tlet filter: GitIgnoreFilter | undefined;\n\t\tif (this.getIgnoreFilter != null) {\n\t\t\tfilter = this.getIgnoreFilter(repoPath, gitDir.uri.fsPath);\n\t\t}\n\n\t\tconst check = this.getIgnorePathChecker?.(repoPath);\n\t\tconst deliverUnchecked = this.trackedPruning && check == null;\n\t\tlet filterReady = filter == null || deliverUnchecked;\n\t\tlet buffered: FileWatchEvent[] | undefined = filterReady ? undefined : [];\n\t\tlet bufferIncomplete = false;\n\n\t\tconst rootPrefix = repoPath.endsWith('/') ? repoPath : `${repoPath}/`;\n\t\tconst getRelativeEventPath = (path: string): string | undefined => {\n\t\t\tif (!isWindows && path.startsWith('/') && repoPath.startsWith('/')) {\n\t\t\t\tconst prefix = path.slice(0, rootPrefix.length);\n\t\t\t\tif (prefix !== rootPrefix && (isLinux || prefix.toLowerCase() !== rootPrefix.toLowerCase())) {\n\t\t\t\t\treturn undefined;\n\t\t\t\t}\n\n\t\t\t\treturn path.slice(prefix.length);\n\t\t\t}\n\n\t\t\treturn isDescendant(path, repoPath) ? relative(repoPath, path) : undefined;\n\t\t};\n\t\tconst revalidated = filter?.revalidate();\n\t\tif (!filterReady && filter != null) {\n\t\t\tconst replay = (): void => {\n\t\t\t\tconst pending = buffered;\n\t\t\t\tconst incomplete = bufferIncomplete;\n\t\t\t\tfilterReady = true;\n\t\t\t\tbuffered = undefined;\n\t\t\t\tbufferIncomplete = false;\n\n\t\t\t\tif (entry == null || this.wtWatchers.get(repoPath) !== entry) return;\n\n\t\t\t\tconst deliver: string[] = [];\n\t\t\t\tfor (const event of pending ?? []) {\n\t\t\t\t\tconst relativePath = getRelativeEventPath(event.path);\n\t\t\t\t\tif (\n\t\t\t\t\t\trelativePath != null &&\n\t\t\t\t\t\tthis.shouldDeliverWorkingTreePath(entry, event.path, relativePath, event.reason === 'delete')\n\t\t\t\t\t) {\n\t\t\t\t\t\tdeliver.push(event.path);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (deliver.length || incomplete) {\n\t\t\t\t\tsession.pushWorkingTreeChanges(deliver, incomplete);\n\t\t\t\t}\n\t\t\t};\n\t\t\tvoid filter\n\t\t\t\t.ready()\n\t\t\t\t.then(replay, replay)\n\t\t\t\t.catch(() => {});\n\t\t}\n\n\t\tconst onIgnoreRulesChanged = (refreshFilter: boolean, reason: 'worktree' | 'recovery' = 'worktree'): void => {\n\t\t\tif (refreshFilter && filter != null) {\n\t\t\t\tthis.reloadIgnoreFilter(filter, reason !== 'worktree' && entry?.delegation != null);\n\t\t\t}\n\t\t\tif (entry != null) {\n\t\t\t\tthis.invalidateIgnoreCheck(entry);\n\t\t\t\tthis.scheduleIgnorePruningRefresh(entry, reason);\n\t\t\t}\n\t\t\tfor (const h of watchHooks) {\n\t\t\t\th.onGitIgnoreChanged?.(repoPath);\n\t\t\t}\n\t\t\tsession.pushUnfencedRepoChanges(['ignores']);\n\t\t};\n\n\t\tconst isNoise = createWorkingTreeNoiseFilter(repoPath);\n\n\t\tconst onEvent = (event: FileWatchEvent): void => {\n\t\t\tconst startingDelegation = entry?.starting === true && entry.delegation != null;\n\t\t\tif (event.reason === 'overflow') {\n\t\t\t\tonIgnoreRulesChanged(true, 'recovery');\n\t\t\t\tif (entry?.delegation == null || !this.trackedPruning) {\n\t\t\t\t\tsession.pushWorkingTreeChanges([], true);\n\t\t\t\t}\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (isNoise(event.path)) return;\n\n\t\t\tconst relativePath = getRelativeEventPath(event.path);\n\t\t\tif (relativePath === '.gitignore') {\n\t\t\t\tonIgnoreRulesChanged(true);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (\n\t\t\t\trelativePath?.endsWith('/.gitignore') &&\n\t\t\t\t(deliverUnchecked ||\n\t\t\t\t\tentry?.delegation != null ||\n\t\t\t\t\t!(filterReady && filter?.isIgnored(relativePath.slice(0, -'.gitignore'.length))))\n\t\t\t) {\n\t\t\t\tonIgnoreRulesChanged(true);\n\t\t\t}\n\n\t\t\tif (startingDelegation) return;\n\n\t\t\tif (!filterReady) {\n\t\t\t\tif (buffered != null && buffered.length >= maxBufferedWorkingTreePaths) {\n\t\t\t\t\tbufferIncomplete = true;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tbuffered?.push(event);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (entry != null && this.wtWatchers.get(repoPath) !== entry) return;\n\n\t\t\tif (\n\t\t\t\tdeliverUnchecked ||\n\t\t\t\tentry == null ||\n\t\t\t\tthis.shouldDeliverWorkingTreePath(entry, event.path, relativePath, event.reason === 'delete')\n\t\t\t) {\n\t\t\t\tsession.pushWorkingTreeChanges([event.path]);\n\t\t\t}\n\t\t};\n\n\t\tconst kept = check == null && canPrune && filter != null ? this.keptIgnoredDirectories.get(filter) : undefined;\n\t\tconst eligible =\n\t\t\tthis.getGitIgnoreWatchInputs != null &&\n\t\t\t(this.trackedPruning\n\t\t\t\t? this.watchGroups.get((gitDir.commonUri ?? gitDir.uri).fsPath)?.hasLiveMetadataCoverage(repoPath)\n\t\t\t\t: check == null && this.isConnected(record));\n\t\tconst created =\n\t\t\t(eligible ? this.createWorkingTreeWatcher(repoPath, onEvent, workingTreeExcludes, true) : undefined) ??\n\t\t\tthis.createWorkingTreeWatcher(\n\t\t\t\trepoPath,\n\t\t\t\tonEvent,\n\t\t\t\tkept != null ? [...workingTreeExcludes, ...kept] : workingTreeExcludes,\n\t\t\t);\n\t\tentry = {\n\t\t\tignoreCheck: check && {\n\t\t\t\tcheck: check,\n\t\t\t\tpaths: new Map(),\n\t\t\t\tincomplete: false,\n\t\t\t},\n\t\t\tsession: session,\n\t\t\tonEvent: onEvent,\n\t\t\tfilter: filter,\n\t\t\twatcher: created.watcher,\n\t\t\tdelegation: created.delegation,\n\t\t\tignoredDirectories: created.delegation == null ? (kept ?? []) : [],\n\t\t\tgeneration: 0,\n\t\t\treading: false,\n\t\t\trereadQueued: false,\n\t\t\treliability: 'reliable',\n\t\t\tstarting: created.awaitingStartAck || created.delegation != null,\n\t\t\tawaitingStartAck: created.awaitingStartAck,\n\t\t};\n\t\tthis.wtWatchers.set(repoPath, entry);\n\t\tthis.reconcileWorkingTreeLifecycle(entry, created.reliability, { initial: true });\n\n\t\tif (entry.delegation != null || (canPrune && kept == null)) {\n\t\t\tthis.refreshIgnorePruning(entry);\n\t\t}\n\n\t\tvoid revalidated?.then(\n\t\t\tchanged => {\n\t\t\t\tif (!changed) return;\n\n\t\t\t\tif (filter != null) {\n\t\t\t\t\tthis.keptIgnoredDirectories.delete(filter);\n\t\t\t\t}\n\t\t\t\tif (this.wtWatchers.get(repoPath) === entry) {\n\t\t\t\t\tonIgnoreRulesChanged(false);\n\t\t\t\t}\n\t\t\t},\n\t\t\t() => {\n\t\t\t\tif (filter != null) {\n\t\t\t\t\tthis.keptIgnoredDirectories.delete(filter);\n\t\t\t\t}\n\t\t\t\tif (this.wtWatchers.get(repoPath) === entry) {\n\t\t\t\t\tonIgnoreRulesChanged(true);\n\t\t\t\t}\n\t\t\t},\n\t\t);\n\t}\n\n\tprivate shouldDeliverWorkingTreePath(\n\t\tentry: WorkingTreeWatcherEntry,\n\t\tpath: string,\n\t\trelativePath: string | undefined,\n\t\tdeleted = false,\n\t): boolean {\n\t\tconst filter = entry.filter;\n\t\tif (relativePath == null || filter == null) return true;\n\n\t\tconst batch = entry.ignoreCheck;\n\t\tif (!filter.isIgnored(relativePath) && !(batch != null && filter.isIgnored(`${relativePath}/`))) return true;\n\n\t\tif (batch == null) {\n\t\t\tif (entry.delegation == null && this.canPruneIgnoredDirectories()) {\n\t\t\t\tthis.onIgnoredEvent(entry, filter, relativePath);\n\t\t\t}\n\t\t\treturn false;\n\t\t}\n\n\t\tif (batch.incomplete) return false;\n\n\t\tconst previous = batch.paths.get(path);\n\t\tif (this._suspended || (batch.paths.size >= maxIgnoreCheckPaths && previous == null)) {\n\t\t\tbatch.paths.clear();\n\t\t\tbatch.incomplete = true;\n\t\t} else {\n\t\t\tbatch.paths.set(path, { relativePath: relativePath, deleted: deleted || previous?.deleted === true });\n\t\t}\n\t\tthis.scheduleIgnoreCheck(entry, batch);\n\t\treturn false;\n\t}\n\n\tprivate invalidateIgnoreCheck(entry: WorkingTreeWatcherEntry): void {\n\t\tconst batch = entry.ignoreCheck;\n\t\tif (batch == null) return;\n\n\t\tif (batch.controller != null || batch.paths.size) {\n\t\t\tclearTimeout(batch.timer);\n\t\t\tbatch.timer = undefined;\n\t\t\tbatch.controller?.abort();\n\t\t\tbatch.controller = undefined;\n\t\t\tbatch.paths.clear();\n\t\t\tbatch.incomplete = true;\n\t\t}\n\t\tthis.scheduleIgnoreCheck(entry, batch);\n\t}\n\n\tprivate scheduleIgnoreCheck(entry: WorkingTreeWatcherEntry, batch: IgnoreCheckBatch): void {\n\t\tif (\n\t\t\tthis._suspended ||\n\t\t\tbatch.controller != null ||\n\t\t\tbatch.timer != null ||\n\t\t\t(!batch.paths.size && !batch.incomplete)\n\t\t) {\n\t\t\treturn;\n\t\t}\n\n\t\tbatch.timer = setTimeout(() => {\n\t\t\tbatch.timer = undefined;\n\t\t\tvoid this.flushIgnoreCheck(entry, batch);\n\t\t}, ignoreCheckDelayMs);\n\t}\n\n\tprivate async flushIgnoreCheck(entry: WorkingTreeWatcherEntry, batch: IgnoreCheckBatch): Promise<void> {\n\t\tif (batch.incomplete) {\n\t\t\tbatch.incomplete = false;\n\t\t\tentry.session.pushWorkingTreeChanges([], true);\n\t\t\treturn;\n\t\t}\n\n\t\tconst paths = batch.paths;\n\t\tconst generation = entry.generation;\n\t\tbatch.paths = new Map();\n\t\tconst controller = new AbortController();\n\t\tbatch.controller = controller;\n\t\tlet ignored: ReadonlySet<string> | undefined;\n\t\ttry {\n\t\t\tignored = await batch.check(\n\t\t\t\tArray.from(paths.values(), item => item.relativePath),\n\t\t\t\tcontroller.signal,\n\t\t\t);\n\t\t} catch {\n\t\t\t// KEEP: a failed index check can conceal edits to tracked files.\n\t\t}\n\t\tif (this.wtWatchers.get(entry.session.repoPath) !== entry || batch.controller !== controller) return;\n\n\t\tbatch.controller = undefined;\n\n\t\tif (ignored == null || generation !== entry.generation) {\n\t\t\tentry.session.pushWorkingTreeChanges([], true);\n\t\t} else {\n\t\t\tconst delivered: string[] = [];\n\t\t\tlet ignoredDeletion = false;\n\t\t\tfor (const [path, { relativePath, deleted }] of paths) {\n\t\t\t\tif (!ignored.has(relativePath)) {\n\t\t\t\t\tdelivered.push(path);\n\t\t\t\t} else {\n\t\t\t\t\tignoredDeletion ||= deleted;\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (delivered.length || ignoredDeletion) {\n\t\t\t\tentry.session.pushWorkingTreeChanges(delivered, ignoredDeletion);\n\t\t\t}\n\t\t}\n\t\tthis.scheduleIgnoreCheck(entry, batch);\n\t}\n\n\tprivate stopWorkingTreeWatcher(repoPath: string): void {\n\t\tconst entry = this.wtWatchers.get(repoPath);\n\t\tif (entry == null) return;\n\n\t\tentry.generation++;\n\t\tclearTimeout(entry.ignoreCheck?.timer);\n\t\tentry.ignoreCheck?.controller?.abort();\n\t\tclearTimeout(entry.refreshTimer);\n\t\tentry.refreshTimer = undefined;\n\t\tthis.wtWatchers.delete(repoPath);\n\t\tentry.watcher?.dispose();\n\t\tif (entry.pollTarget != null) {\n\t\t\tthis.poller?.delete(entry.pollTarget);\n\t\t\tentry.pollTarget = undefined;\n\t\t}\n\t}\n\n\tprivate createWorkingTreeWatcher(\n\t\trepoPath: string,\n\t\tonEvent: (event: FileWatchEvent) => void,\n\t\texcludes: readonly string[],\n\t): CreatedWorkingTreeWatcher;\n\tprivate createWorkingTreeWatcher(\n\t\trepoPath: string,\n\t\tonEvent: (event: FileWatchEvent) => void,\n\t\texcludes: readonly string[],\n\t\ttryDelegation: true,\n\t): CreatedWorkingTreeWatcher | undefined;\n\tprivate createWorkingTreeWatcher(\n\t\trepoPath: string,\n\t\tonEvent: (event: FileWatchEvent) => void,\n\t\texcludes: readonly string[],\n\t\ttryDelegation = false,\n\t): CreatedWorkingTreeWatcher | undefined {\n\t\tlet watcher: FileWatcher | undefined;\n\t\tlet started = false;\n\t\tconst onDidStart = (): void => {\n\t\t\tif (started) return;\n\n\t\t\tstarted = true;\n\t\t\tconst entry = this.wtWatchers.get(repoPath);\n\t\t\tif (watcher != null && entry?.watcher === watcher) {\n\t\t\t\tentry.awaitingStartAck = false;\n\t\t\t\tthis.reconcileWorkingTreeLifecycle(entry, entry.reliability, { rescan: entry.delegation == null });\n\t\t\t\tif (this.trackedPruning && entry.delegation?.initialApplied && !entry.delegation.verified) {\n\t\t\t\t\tthis.refreshIgnorePruning(entry);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\n\t\tlet reliability: FileWatcherReliability = 'reliable';\n\t\tconst onDidChangeReliability = (state: FileWatcherReliability): void => {\n\t\t\tif (watcher == null) {\n\t\t\t\treliability = state;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst entry = this.wtWatchers.get(repoPath);\n\t\t\tif (entry?.watcher === watcher) {\n\t\t\t\tthis.reconcileWorkingTreeLifecycle(entry, state);\n\t\t\t}\n\t\t};\n\t\tconst options: FileWatcherOptions = {\n\t\t\texcludes: excludes,\n\t\t\tonDidStart: onDidStart,\n\t\t\t...(this.poller != null || this.trackedPruning\n\t\t\t\t? { onDidChangeReliability: onDidChangeReliability }\n\t\t\t\t: undefined),\n\t\t};\n\t\tconst emit = (event: FileWatchEvent): void => {\n\t\t\tif (watcher == null ? !tryDelegation : this.wtWatchers.get(repoPath)?.watcher === watcher) {\n\t\t\t\tonEvent(event);\n\t\t\t}\n\t\t};\n\t\tif (tryDelegation) {\n\t\t\tconst delegated = this.provider.createGitIgnoringWatcher?.(repoPath, emit, options);\n\t\t\tif (delegated == null) return undefined;\n\n\t\t\twatcher = delegated;\n\t\t\treturn {\n\t\t\t\twatcher: watcher,\n\t\t\t\treliability: reliability,\n\t\t\t\tawaitingStartAck: (this.provider.callsOnDidStart === true || this.trackedPruning) && !started,\n\t\t\t\tdelegation: { watcher: delegated, initialApplied: false, refreshing: false, verified: false },\n\t\t\t};\n\t\t}\n\n\t\twatcher = this.provider.createWatcher(repoPath, '**', emit, options);\n\t\treturn {\n\t\t\twatcher: watcher,\n\t\t\treliability: reliability,\n\t\t\tawaitingStartAck: this.provider.callsOnDidStart === true && !started,\n\t\t};\n\t}\n\n\tprivate replaceWithCoveredWatcher(entry: WorkingTreeWatcherEntry): void {\n\t\tconst previous = entry.watcher;\n\t\tlet created: CreatedWorkingTreeWatcher | undefined;\n\t\ttry {\n\t\t\tcreated = this.createWorkingTreeWatcher(entry.session.repoPath, entry.onEvent, workingTreeExcludes, true);\n\t\t\tif (created == null) return;\n\t\t} catch {\n\t\t\treturn;\n\t\t}\n\n\t\tentry.watcher = created.watcher;\n\t\tentry.delegation = created.delegation;\n\t\tentry.awaitingStartAck = created.awaitingStartAck;\n\t\tentry.starting = created.awaitingStartAck || created.delegation != null;\n\t\tprevious?.dispose();\n\t\tthis.reconcileWorkingTreeLifecycle(entry, created.reliability, { initial: true, rescan: !entry.starting });\n\t\tthis.refreshIgnorePruning(entry);\n\t}\n\n\tprivate reconcileWorkingTreeLifecycle(\n\t\tentry: WorkingTreeWatcherEntry,\n\t\tstate: FileWatcherReliability,\n\t\toptions?: { initial?: boolean; rescan?: boolean },\n\t): void {\n\t\tconst unavailable = state === 'unwatchable';\n\t\tconst availabilityChanged = !options?.initial && unavailable !== (entry.reliability === 'unwatchable');\n\t\tconst delegation = entry.delegation;\n\t\tentry.reliability = state;\n\t\tif (unavailable && (delegation == null || !this.trackedPruning)) {\n\t\t\tentry.awaitingStartAck = false;\n\t\t}\n\n\t\tif (availabilityChanged && delegation != null) {\n\t\t\tif (unavailable) {\n\t\t\t\tentry.generation++;\n\t\t\t\tif (entry.starting) {\n\t\t\t\t\tdelegation.verified = false;\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\tthis.refreshWorkingTreeFilter(entry.session.repoPath, 'recovery');\n\t\t\t}\n\t\t}\n\n\t\tconst rulesVerified = delegation?.verified !== false;\n\t\tconst startupReady = entry.starting && !unavailable && !entry.awaitingStartAck && rulesVerified;\n\t\tconst reconcileAvailability =\n\t\t\tavailabilityChanged && (unavailable || (rulesVerified && !(this.trackedPruning && delegation != null)));\n\t\tif (startupReady || (availabilityChanged && unavailable && delegation == null)) {\n\t\t\tentry.starting = false;\n\t\t}\n\n\t\tthis.updateWorkingTreePollTarget(entry);\n\t\tif (startupReady || reconcileAvailability || options?.rescan) {\n\t\t\tentry.session.pushWorkingTreeChanges([], true);\n\t\t}\n\n\t\tconst record = this.sessionMap.get(entry.session.repoPath);\n\t\tif (record != null) {\n\t\t\tthis.updateWatchMode(record);\n\t\t}\n\t}\n\n\t/** Polls the host's working-tree fingerprint, when it gives one, while the watcher isn't `reliable` */\n\tprivate updateWorkingTreePollTarget(entry: WorkingTreeWatcherEntry): void {\n\t\tconst poller = this.poller;\n\t\tconst getFingerprint = poller?.options.getWorkingTreeFingerprint;\n\t\tif (poller == null) return;\n\n\t\tif (entry.reliability === 'reliable' || (getFingerprint == null && entry.watcher != null)) {\n\t\t\tif (entry.pollTarget != null) {\n\t\t\t\tpoller.delete(entry.pollTarget);\n\t\t\t\tentry.pollTarget = undefined;\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tif (entry.pollTarget != null) return;\n\n\t\tconst repoPath = entry.session.repoPath;\n\t\tlet last: string | undefined;\n\t\tconst target: PollTarget = {\n\t\t\tpoll: async (): Promise<void> => {\n\t\t\t\tif (entry.pollTarget !== target) return;\n\n\t\t\t\tif (entry.watcher == null) {\n\t\t\t\t\tthis.placeFallbackWorkingTreeWatcher(entry);\n\t\t\t\t}\n\t\t\t\tif (getFingerprint == null || entry.pollTarget !== target) return;\n\n\t\t\t\tlet fingerprint: string | undefined;\n\t\t\t\ttry {\n\t\t\t\t\tfingerprint = await getFingerprint(repoPath);\n\t\t\t\t} catch {\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t\tif (fingerprint == null || entry.pollTarget !== target) return;\n\n\t\t\t\tconst moved = last != null && last !== fingerprint;\n\t\t\t\tlast = fingerprint;\n\t\t\t\t// A fingerprint says the tree moved, not which files did\n\t\t\t\tif (moved) {\n\t\t\t\t\tentry.session.pushWorkingTreeChanges([], true);\n\t\t\t\t}\n\t\t\t},\n\t\t};\n\t\tentry.pollTarget = target;\n\t\tpoller.add(target);\n\t}\n\n\tprivate canPruneIgnoredDirectories(): boolean {\n\t\treturn !this.trackedPruning && this.provider.supportsExcludes === true && this.getIgnoredDirectories != null;\n\t}\n\n\t/**\n\t * An event the gitignore post-filter dropped. When its directory is itself ignored, the watcher is watching an\n\t * ignored directory it could prune (one created after the last read), so the ignored set is read again. An ignored\n\t * file in a watched directory (a root `.env`, `src/debug.log`) triggers nothing.\n\t */\n\tprivate onIgnoredEvent(entry: WorkingTreeWatcherEntry, filter: GitIgnoreFilter, relativePath: string): void {\n\t\tif (entry.refreshTimer != null || entry.rereadQueued) return;\n\n\t\tlet ignoredDir: string | undefined;\n\t\tfor (let slash = relativePath.indexOf('/'); slash !== -1; slash = relativePath.indexOf('/', slash + 1)) {\n\t\t\tconst dir = relativePath.slice(0, slash);\n\t\t\tif (entry.unpruned?.has(dir) || entry.unprunable?.has(dir)) return;\n\t\t\tif (filter.isIgnored(`${dir}/`)) {\n\t\t\t\tignoredDir = dir;\n\t\t\t\tbreak;\n\t\t\t}\n\t\t}\n\t\tif (ignoredDir == null) return;\n\n\t\tentry.unpruned ??= new Set();\n\t\tentry.unpruned.add(ignoredDir);\n\n\t\tif (entry.reading) {\n\t\t\tentry.rereadQueued = true;\n\t\t\treturn;\n\t\t}\n\n\t\tthis.armIgnorePruningRefresh(entry);\n\t}\n\n\tprivate scheduleIgnorePruningRefresh(\n\t\tentry: WorkingTreeWatcherEntry,\n\t\treason: Exclude<GitIgnoreRefreshReason, 'initial'>,\n\t): void {\n\t\tif (entry.filter != null) {\n\t\t\tthis.keptIgnoredDirectories.delete(entry.filter);\n\t\t}\n\t\tif (entry.delegation == null && (entry.ignoreCheck != null || !this.canPruneIgnoredDirectories())) return;\n\n\t\tconst delegation = entry.delegation;\n\t\tif (delegation != null) {\n\t\t\tif (entry.starting) {\n\t\t\t\tdelegation.verified = false;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tdelegation.pendingRefresh == null ||\n\t\t\t\tdelegation.pendingRefresh === 'worktree' ||\n\t\t\t\treason === 'recovery'\n\t\t\t) {\n\t\t\t\tdelegation.pendingRefresh = reason;\n\t\t\t}\n\t\t}\n\n\t\tentry.generation++;\n\t\tentry.unprunable = undefined;\n\t\tclearTimeout(entry.refreshTimer);\n\t\tthis.armIgnorePruningRefresh(entry);\n\t}\n\n\tprivate armIgnorePruningRefresh(entry: WorkingTreeWatcherEntry): void {\n\t\tentry.refreshTimer = setTimeout(() => {\n\t\t\tentry.refreshTimer = undefined;\n\t\t\tconst repoPath = entry.session.repoPath;\n\t\t\tif (this.wtWatchers.get(repoPath) !== entry) return;\n\n\t\t\tthis.refreshIgnorePruning(entry);\n\t\t}, ignorePruningRefreshDelayMs);\n\t}\n\n\tprivate refreshIgnorePruning(entry: WorkingTreeWatcherEntry): void {\n\t\tif (this.wtWatchers.get(entry.session.repoPath) !== entry) return;\n\n\t\tconst delegation = entry.delegation;\n\t\tif (delegation != null) {\n\t\t\tif (this.trackedPruning && delegation.initialApplied && entry.awaitingStartAck) return;\n\n\t\t\tif (!delegation.refreshing && (!delegation.initialApplied || entry.reliability !== 'unwatchable')) {\n\t\t\t\tvoid this.refreshDelegatedIgnores(entry, delegation);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\n\t\tif (entry.watcher == null || entry.ignoreCheck != null || !this.canPruneIgnoredDirectories()) {\n\t\t\treturn;\n\t\t}\n\t\tif (entry.reading) {\n\t\t\tentry.rereadQueued = true;\n\t\t\treturn;\n\t\t}\n\n\t\tvoid this.refreshIgnoredDirectories(entry);\n\t}\n\n\tprivate async refreshIgnoredDirectories(entry: WorkingTreeWatcherEntry): Promise<void> {\n\t\tconst getIgnoredDirectories = this.getIgnoredDirectories;\n\t\tif (getIgnoredDirectories == null) return;\n\n\t\tentry.reading = true;\n\t\ttry {\n\t\t\tconst generation = entry.generation;\n\t\t\tconst unpruned = entry.unpruned?.size ? [...entry.unpruned] : undefined;\n\n\t\t\tlet directories: readonly string[] | undefined;\n\t\t\ttry {\n\t\t\t\tdirectories = await getIgnoredDirectories(entry.session.repoPath);\n\t\t\t} catch {\n\t\t\t\tdirectories = undefined;\n\t\t\t}\n\n\t\t\tif (entry.generation === generation) {\n\t\t\t\tif (directories != null) {\n\t\t\t\t\tthis.swapWorkingTreeWatcher(entry, directories);\n\t\t\t\t\tif (entry.filter != null) {\n\t\t\t\t\t\tthis.keptIgnoredDirectories.set(entry.filter, directories);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\tif (unpruned != null) {\n\t\t\t\t\tthis.settleUnprunedDirectories(entry, unpruned, directories);\n\t\t\t\t}\n\t\t\t}\n\t\t} finally {\n\t\t\tentry.reading = false;\n\n\t\t\tif (entry.rereadQueued) {\n\t\t\t\tentry.rereadQueued = false;\n\t\t\t\tif (entry.refreshTimer == null && this.wtWatchers.get(entry.session.repoPath) === entry) {\n\t\t\t\t\tthis.refreshIgnorePruning(entry);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate async refreshDelegatedIgnores(\n\t\tentry: WorkingTreeWatcherEntry,\n\t\tdelegation: GitIgnoreDelegation,\n\t): Promise<void> {\n\t\tconst repoPath = entry.session.repoPath;\n\t\tconst generation = entry.generation;\n\t\tconst initial = !delegation.initialApplied;\n\t\tconst verifyingStartup = !initial && !delegation.verified;\n\t\tconst reason = initial ? 'initial' : verifyingStartup ? 'recovery' : (delegation.pendingRefresh ?? 'worktree');\n\t\tdelegation.refreshing = true;\n\n\t\ttry {\n\t\t\tconst record = this.sessionMap.get(repoPath);\n\t\t\tconst refreshConfig = verifyingStartup || (this.trackedPruning && reason !== 'worktree');\n\t\t\tconst reloadAfterRead =\n\t\t\t\trefreshConfig && (initial || verifyingStartup || !entry.filter?.canInvalidateConfig);\n\t\t\tlet inputs: GitIgnoreWatchInputs | undefined;\n\t\t\ttry {\n\t\t\t\tif (record != null) {\n\t\t\t\t\tinputs = await this.getGitIgnoreWatchInputs?.(repoPath, record.gitDir, {\n\t\t\t\t\t\trefreshConfig: reloadAfterRead,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t} finally {\n\t\t\t\tif (refreshConfig && entry.generation === generation && entry.delegation === delegation) {\n\t\t\t\t\tawait (reloadAfterRead ? entry.filter?.refresh() : entry.filter?.ready());\n\t\t\t\t}\n\t\t\t}\n\t\t\tif (entry.generation !== generation || entry.delegation !== delegation) return;\n\t\t\tif (\n\t\t\t\tinputs == null ||\n\t\t\t\t(this.trackedPruning &&\n\t\t\t\t\t(!Array.isArray(inputs.protectedPaths) || !Array.isArray(inputs.configWatchPaths)))\n\t\t\t) {\n\t\t\t\tthis.relinquishIgnoreDelegation(entry);\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tawait delegation.watcher.refreshGitIgnores(reason, inputs);\n\t\t\tif (entry.delegation !== delegation || this.wtWatchers.get(repoPath) !== entry) return;\n\t\t\tif (initial) {\n\t\t\t\tdelegation.initialApplied = true;\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tawait entry.filter?.ready().catch(() => undefined);\n\t\t\tif (entry.generation !== generation || entry.delegation !== delegation) return;\n\n\t\t\tdelegation.verified = true;\n\t\t\tthis.reconcileWorkingTreeLifecycle(entry, entry.reliability, {\n\t\t\t\trescan: !verifyingStartup && !entry.starting,\n\t\t\t});\n\t\t} catch {\n\t\t\tif (\n\t\t\t\tentry.generation === generation &&\n\t\t\t\tthis.wtWatchers.get(repoPath) === entry &&\n\t\t\t\tentry.delegation === delegation\n\t\t\t) {\n\t\t\t\tthis.relinquishIgnoreDelegation(entry);\n\t\t\t}\n\t\t} finally {\n\t\t\tdelegation.refreshing = false;\n\t\t\tif (entry.generation === generation) {\n\t\t\t\tdelegation.pendingRefresh = undefined;\n\t\t\t}\n\t\t\tif (\n\t\t\t\tentry.delegation === delegation &&\n\t\t\t\tthis.wtWatchers.get(repoPath) === entry &&\n\t\t\t\tentry.refreshTimer == null &&\n\t\t\t\t(delegation.pendingRefresh != null || (delegation.initialApplied && !delegation.verified))\n\t\t\t) {\n\t\t\t\tthis.refreshIgnorePruning(entry);\n\t\t\t}\n\t\t}\n\t}\n\n\tprivate relinquishIgnoreDelegation(entry: WorkingTreeWatcherEntry): void {\n\t\tconst delegation = entry.delegation;\n\t\tif (delegation == null) return;\n\n\t\tentry.delegation = undefined;\n\t\tentry.watcher = undefined;\n\t\tentry.starting = false;\n\t\tentry.awaitingStartAck = false;\n\t\tentry.generation++;\n\t\tclearTimeout(entry.refreshTimer);\n\t\tentry.refreshTimer = undefined;\n\t\tdelegation.watcher.dispose();\n\n\t\tthis.placeFallbackWorkingTreeWatcher(entry, true);\n\t}\n\n\tprivate placeFallbackWorkingTreeWatcher(entry: WorkingTreeWatcherEntry, withdrawing = false): void {\n\t\tlet created: CreatedWorkingTreeWatcher;\n\t\ttry {\n\t\t\tcreated = this.createWorkingTreeWatcher(entry.session.repoPath, entry.onEvent, workingTreeExcludes);\n\t\t} catch {\n\t\t\tthis.reconcileWorkingTreeLifecycle(entry, 'unwatchable', { initial: true, rescan: withdrawing });\n\t\t\treturn;\n\t\t}\n\n\t\tentry.watcher = created.watcher;\n\t\tentry.awaitingStartAck = created.awaitingStartAck;\n\t\tentry.starting = created.awaitingStartAck;\n\t\tthis.reconcileWorkingTreeLifecycle(entry, created.reliability, {\n\t\t\tinitial: true,\n\t\t\trescan: !entry.starting || created.reliability === 'unwatchable',\n\t\t});\n\t\tthis.refreshIgnorePruning(entry);\n\t}\n\n\t/**\n\t * A directory the read left unexcluded is one git won't prune (or the read failed), so it never triggers a read\n\t * again until ignore rules change — otherwise each of its events would spawn git.\n\t */\n\tprivate settleUnprunedDirectories(\n\t\tentry: WorkingTreeWatcherEntry,\n\t\tunpruned: readonly string[],\n\t\tdirectories: readonly string[] | undefined,\n\t): void {\n\t\tfor (const dir of unpruned) {\n\t\t\tentry.unpruned?.delete(dir);\n\t\t\tif (directories?.some(d => d === dir || dir.startsWith(`${d}/`))) continue;\n\n\t\t\tentry.unprunable ??= new Set();\n\t\t\tentry.unprunable.add(dir);\n\t\t}\n\t}\n\n\tprivate swapWorkingTreeWatcher(entry: WorkingTreeWatcherEntry, directories: readonly string[]): void {\n\t\tconst previous = entry.ignoredDirectories;\n\t\tif (previous.length === directories.length && previous.every(d => directories.includes(d))) return;\n\n\t\tlet created: CreatedWorkingTreeWatcher;\n\t\ttry {\n\t\t\tcreated = this.createWorkingTreeWatcher(entry.session.repoPath, entry.onEvent, [\n\t\t\t\t...workingTreeExcludes,\n\t\t\t\t...directories,\n\t\t\t]);\n\t\t} catch {\n\t\t\treturn;\n\t\t}\n\n\t\tconst previousWatcher = entry.watcher;\n\t\tentry.watcher = created.watcher;\n\t\tentry.awaitingStartAck = created.awaitingStartAck;\n\t\tentry.starting = created.awaitingStartAck;\n\t\tentry.ignoredDirectories = directories;\n\t\tpreviousWatcher?.dispose();\n\t\tthis.reconcileWorkingTreeLifecycle(entry, created.reliability, {\n\t\t\trescan: previous.some(d => !directories.some(n => n === d || d.startsWith(`${n}/`))),\n\t\t});\n\t}\n\n\tprivate refreshWorkingTreeFilter(repoPath: string, reason: 'metadata' | 'recovery' = 'metadata'): void {\n\t\tconst entry = this.wtWatchers.get(repoPath);\n\t\tif (entry == null) return;\n\n\t\tthis.invalidateIgnoreCheck(entry);\n\t\tif (entry.filter != null) {\n\t\t\tthis.reloadIgnoreFilter(entry.filter, entry.delegation != null);\n\t\t}\n\t\tthis.scheduleIgnorePruningRefresh(entry, reason);\n\t}\n\n\tprivate reloadIgnoreFilter(filter: GitIgnoreFilter, delegatedConfigChange: boolean): void {\n\t\tconst configChanged = delegatedConfigChange && this.trackedPruning;\n\t\tif (configChanged && !filter.canInvalidateConfig) return;\n\n\t\tvoid filter.refresh({ configChanged: configChanged });\n\t}\n\n\tprivate disposeSessionRecord(record: SessionRecord): void {\n\t\t// The working tree first: with it still up, leaving the group would read as a move back to `'events'` and\n\t\t// announce one for a repository that is going away\n\t\tthis.stopWorkingTreeWatcher(record.session.repoPath);\n\t\tthis.disconnectFromWatchGroup(record);\n\t\tthis.updateWatchMode(record);\n\t\trecord.session.dispose();\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;AAgCA,MAAM,8BAA8B;AAEpC,MAAM,sBAAsB;AAC5B,MAAM,qBAAqB;AAY3B,MAAM,8BAA8B;;;;;;;;;;;;AA8LpC,IAAa,yBAAb,MAAiE;CAChE,yBAA0C,IAAI,QAAgC;;CAE9E,IAAI,wBAAuD;EAC1D,OAAO,KAAK,uBAAuB;CACpC;CAEA,0BAA2C,IAAI,QAAgB;;;CAG/D,IAAI,yBAAwC;EAC3C,OAAO,KAAK,wBAAwB;CACrC;CAEA,wBAAyC,IAAI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K,gBAAgB,MAAM;EAC3B,OAAO,QAAQ,QAAQ;CACxB;AACD"}
|
|
@@ -74,7 +74,7 @@ export declare function shouldIgnoreWorkingTreePath(relativePath: string): boole
|
|
|
74
74
|
* Creates the per-event noise check for a working-tree watcher. It judges only the part of an absolute event path
|
|
75
75
|
* inside `repoPath`, so folders above the root (`app.git/feature`, a `node_modules` ancestor) never count. The root is
|
|
76
76
|
* compiled once here, so an event costs one anchored match and a scan of its tail, with no path normalization. The
|
|
77
|
-
* match
|
|
77
|
+
* match uses POSIX separators for absolute POSIX paths and tolerates case differences off Linux.
|
|
78
78
|
*
|
|
79
79
|
* A path not under the root is judged whole.
|
|
80
80
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { escapeRegex } from "../../utils/string.js";
|
|
2
|
-
import { isLinux } from "../../utils/platform.js";
|
|
2
|
+
import { isLinux, isWindows } from "../../utils/platform.js";
|
|
3
3
|
import { getBestPath, isAbsolute } from "../../utils/path.js";
|
|
4
4
|
//#region ../git/src/watching/watcherPatterns.ts
|
|
5
5
|
const dotGitFiles = "index,HEAD,*_HEAD,MERGE_*,rebase-apply,rebase-apply/**,rebase-merge,rebase-merge/**,sequencer,sequencer/**";
|
|
@@ -158,9 +158,10 @@ function shouldIgnoreRepoPath(relativePath) {
|
|
|
158
158
|
return ignoredRepoPathRegex.test(relativePath);
|
|
159
159
|
}
|
|
160
160
|
const ignoredWorkingTreePathRegex = /(?<![^\\/])(?:(?:node_modules|\.git)(?:[\\/]|$)|\.watchman-cookie-)/g;
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
161
|
+
const ignoredPosixWorkingTreePathRegex = /(?<![^/])(?:(?:node_modules|\.git)(?:\/|$)|\.watchman-cookie-)/g;
|
|
162
|
+
function isIgnoredWorkingTreePathFrom(path, from, pattern = ignoredWorkingTreePathRegex) {
|
|
163
|
+
pattern.lastIndex = from;
|
|
164
|
+
return pattern.test(path);
|
|
164
165
|
}
|
|
165
166
|
/**
|
|
166
167
|
* Returns true if the working tree path, relative to the repository root, should be ignored
|
|
@@ -173,15 +174,20 @@ function shouldIgnoreWorkingTreePath(relativePath) {
|
|
|
173
174
|
* Creates the per-event noise check for a working-tree watcher. It judges only the part of an absolute event path
|
|
174
175
|
* inside `repoPath`, so folders above the root (`app.git/feature`, a `node_modules` ancestor) never count. The root is
|
|
175
176
|
* compiled once here, so an event costs one anchored match and a scan of its tail, with no path normalization. The
|
|
176
|
-
* match
|
|
177
|
+
* match uses POSIX separators for absolute POSIX paths and tolerates case differences off Linux.
|
|
177
178
|
*
|
|
178
179
|
* A path not under the root is judged whole.
|
|
179
180
|
*/
|
|
180
181
|
function createWorkingTreeNoiseFilter(repoPath) {
|
|
182
|
+
const posixRoot = !isWindows && repoPath.startsWith("/") ? new RegExp(`${escapeRegex(repoPath.replace(/\/$/, ""))}(?:/|$)`, isLinux ? "y" : "iy") : void 0;
|
|
181
183
|
const root = getBestPath(repoPath);
|
|
182
184
|
const source = root.split("/").map(escapeRegex).join("[\\\\/]");
|
|
183
185
|
const rootRegex = new RegExp(`${root.startsWith("/") ? "" : "[\\\\/]?"}${source}(?:[\\\\/]|$)`, isLinux ? "y" : "iy");
|
|
184
186
|
return (absoluteEventPath) => {
|
|
187
|
+
if (posixRoot != null && absoluteEventPath.startsWith("/")) {
|
|
188
|
+
posixRoot.lastIndex = 0;
|
|
189
|
+
return isIgnoredWorkingTreePathFrom(absoluteEventPath, posixRoot.test(absoluteEventPath) ? posixRoot.lastIndex : 0, ignoredPosixWorkingTreePathRegex);
|
|
190
|
+
}
|
|
185
191
|
rootRegex.lastIndex = 0;
|
|
186
192
|
return isIgnoredWorkingTreePathFrom(absoluteEventPath, rootRegex.test(absoluteEventPath) ? rootRegex.lastIndex : 0);
|
|
187
193
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watcherPatterns.js","names":[],"sources":["../../../../git/src/watching/watcherPatterns.ts"],"sourcesContent":["import { getBestPath, isAbsolute } from '@gitlens/utils/path.js';\nimport { isLinux } from '@gitlens/utils/platform.js';\nimport { escapeRegex } from '@gitlens/utils/string.js';\nimport type { GitDirProbe } from './gitDirPoller.js';\n\n// Glob patterns for watching files inside the .git directory.\n// They represent pure Git knowledge — the library owns these patterns and\n// provides them to the pluggable FileWatcherFactory.\n\nconst dotGitFiles =\n\t'index,HEAD,*_HEAD,MERGE_*,rebase-apply,rebase-apply/**,rebase-merge,rebase-merge/**,sequencer,sequencer/**';\n\n// `worktrees` (the bare entry, no `/*` suffix) is its own pattern: `worktree remove` deletes the whole\n// `worktrees/<id>` subtree in one syscall, and some platforms/watcher backends coalesce a same-instant\n// subtree delete into a single event for the PARENT directory — `worktrees/*` alone never matches that.\n// `classifyGitDirChange` classifies a bare `worktrees` path, so this is watch-coverage only.\n//\n// Only what `git worktree list` reports per worktree is watched here (its HEAD, lock and location). A\n// linked worktree's own index, `*_HEAD`, `MERGE_*`, rebase and sequencer state is watched by that\n// worktree's root watcher (`dotGitGlobRoot`) instead, so it never wakes sibling worktrees.\nconst dotGitWorktreeFiles = 'worktrees,worktrees/*,worktrees/*/HEAD,worktrees/*/locked,worktrees/*/gitdir';\n\nconst dotGitCommonFiles = `config,gk/config,refs/**,packed-refs,shallow,info/exclude,FETCH_HEAD,${dotGitWorktreeFiles}`;\n\n/** For a checkout whose `.git` directory is the common one (a standard repo or a main checkout): every .git file */\nexport const dotGitGlobCombined = `{${dotGitFiles},${dotGitCommonFiles}}`;\n\n/** For worktree repos: root watcher (worktree-specific files only) */\nexport const dotGitGlobRoot = `{${dotGitFiles}}`;\n\n/** For worktree repos: common watcher (shared config, refs, info, etc.) */\nexport const dotGitGlobCommon = `{${dotGitCommonFiles}}`;\n\nconst dotGitCommonPathRegex = new RegExp(\n\t`^(?:${dotGitCommonFiles\n\t\t.split(',')\n\t\t.map(p =>\n\t\t\tp\n\t\t\t\t.replace(/[.+?^${}()|[\\]\\\\]/g, '\\\\$&')\n\t\t\t\t.replace(/\\/\\*\\*$|\\*/g, glob => (glob === '*' ? '[^/]*' : '(?:/.*)?')),\n\t\t)\n\t\t.join('|')})$`,\n);\n\n/**\n * Whether a path relative to the common `.git` directory is one {@link dotGitGlobCommon} reads: a file every checkout of\n * the repository shares. A trailing `/**` takes in the directory itself, as a watcher's globstar may\n */\nexport function isGitDirCommonPath(relativePath: string): boolean {\n\treturn dotGitCommonPathRegex.test(relativePath);\n}\n\n/**\n * Paths to leave unwatched under the `.git` directory (relative to it), for a provider that prunes natively.\n * Only paths nothing in the globs above reads: never anything under `refs`, `worktrees/*` itself, `gk`, `info`,\n * or the rebase/sequencer directories.\n */\nexport const gitDirExcludes: readonly string[] = [\n\t'objects',\n\t'logs',\n\t'hooks',\n\t'lfs',\n\t'modules',\n\t'rr-cache',\n\t'fsmonitor--daemon*',\n\t'worktrees/*/logs',\n];\n\n/**\n * What a poll stats in a worktree's own `.git` directory when its watcher can't be trusted — the files\n * {@link dotGitGlobRoot} reads.\n */\nexport const gitDirRootProbes: readonly GitDirProbe[] = [\n\t{ path: 'HEAD' },\n\t{ path: 'index' },\n\t{ path: 'ORIG_HEAD' },\n\t{ path: 'MERGE_HEAD' },\n\t{ path: 'CHERRY_PICK_HEAD' },\n\t{ path: 'REVERT_HEAD' },\n\t{ path: 'REBASE_HEAD' },\n\t{ path: 'rebase-merge' },\n\t{ path: 'rebase-apply' },\n\t{ path: 'sequencer' },\n\t// Moves with every commit, reset or checkout on the checked-out branch, without the poll knowing its name\n\t{ path: 'logs/HEAD', emitAs: ['HEAD'] },\n];\n\n/**\n * What a poll stats in the common `.git` directory — the files {@link dotGitGlobCommon} reads, with the `refs/**` it\n * can't list narrowed to its namespace directories (whose mtime moves as a top-level ref is created or deleted) and\n * to the named refs of {@link getGitDirRefProbes}.\n */\nexport const gitDirCommonProbes: readonly GitDirProbe[] = [\n\t{ path: 'packed-refs' },\n\t{ path: 'config' },\n\t{ path: 'gk/config' },\n\t{ path: 'info/exclude' },\n\t{ path: 'refs/heads' },\n\t// Moves as a remote's directory appears or goes: `git remote remove` and `git remote rename` delete or move each of\n\t// its loose refs (a packed one is locked through a loose path too), and git removes the emptied directory. Reported\n\t// as every remote-tracking ref possibly moved, since the poll can't tell which remote it was. A remote whose name\n\t// nests under a directory another remote still uses (`foo/bar` beside `foo/baz`) leaves it unmoved, so only a named\n\t// ref's probe sees that one go\n\t{ path: 'refs/remotes' },\n\t{ path: 'refs/tags' },\n\t{ path: 'refs/stash' },\n\t{ path: 'worktrees' },\n\t{ path: 'shallow' },\n\t// A fetch writes it with the remote-tracking refs it updated, which the poll can't list. Git rewrites it even on a\n\t// fetch that moves nothing, so each fetch is reported as a `remotes` change: the cost of seeing remote-tracking\n\t// refs no subscriber names\n\t{ path: 'FETCH_HEAD', emitAs: ['FETCH_HEAD', 'refs/remotes'] },\n];\n\n/** For each path a probe of {@link gitDirRootProbes} or {@link gitDirCommonProbes} is emitted as, the probes emitted as it */\nexport const gitDirProbesByEmittedPath: ReadonlyMap<string, readonly string[]> = getProbesByEmittedPath([\n\t...gitDirRootProbes,\n\t...gitDirCommonProbes,\n]);\n\nfunction getProbesByEmittedPath(probes: readonly GitDirProbe[]): Map<string, string[]> {\n\tconst map = new Map<string, string[]>();\n\tfor (const probe of probes) {\n\t\tfor (const path of probe.emitAs ?? []) {\n\t\t\tconst paths = map.get(path);\n\t\t\tif (paths == null) {\n\t\t\t\tmap.set(path, [probe.path]);\n\t\t\t} else {\n\t\t\t\tpaths.push(probe.path);\n\t\t\t}\n\t\t}\n\t}\n\treturn map;\n}\n\n/**\n * Probes for named branches and remote-tracking refs: each loose ref file, and each directory between it and its\n * namespace (`refs/heads/feature` for `refs/heads/feature/x`, `refs/remotes/origin`), whose mtime moves as a sibling\n * ref is created or deleted. A ref created in a directory no named ref sits in is left to `packed-refs`, `logs/HEAD`\n * and `FETCH_HEAD`.\n */\nexport function getGitDirRefProbes(refs: Iterable<string>): GitDirProbe[] {\n\tconst paths = new Set<string>();\n\tfor (const ref of refs) {\n\t\tconst namespaceEnd = ref.startsWith('refs/heads/') ? 10 : ref.startsWith('refs/remotes/') ? 12 : -1;\n\t\tif (namespaceEnd === -1) continue;\n\n\t\tfor (let path = ref; path.length > namespaceEnd; path = path.substring(0, path.lastIndexOf('/'))) {\n\t\t\tpaths.add(path);\n\t\t}\n\t}\n\treturn Array.from(paths, path => ({ path: path }));\n}\n\n/**\n * The top-level names under the `.git` directory that the globs above read or a poll stats, as one case-insensitive\n * pattern (a folder may sit on a case-insensitive file system)\n */\nconst watchedGitDirNames = new Set(\n\t[\n\t\t...`${dotGitFiles},${dotGitCommonFiles}`.split(','),\n\t\t...gitDirRootProbes.map(p => p.path),\n\t\t...gitDirCommonProbes.map(p => p.path),\n\t].map(p => p.split('/')[0]),\n);\nconst watchedGitDirNameRegex = new RegExp(\n\t`^(?:${Array.from(watchedGitDirNames, name => name.replace(/[.+?^${}()|[\\]\\\\]/g, '\\\\$&').replace(/\\*/g, '[^/]*')).join('|')})$`,\n\t'i',\n);\n\n/**\n * The registered folders whose worktrees core ignores, each as a `/`-separated literal path relative to a repository's\n * common git dir, without `.` or empty segments; any other is dropped. A folder must lie strictly inside the common git\n * dir (never absolute, never through `..`), name no glob syntax (a picomatch group or extglob's parentheses and `|`\n * included) or `:` (a watcher's exclude would read it as a pattern, so `(refs|x)` would leave `refs` unwatched, or a\n * drive), and not lie under `worktrees`, whose admin entries are what tells an ignored worktree apart.\n */\nexport function sanitizeIgnoredWorktreeFolders(folders: readonly string[] | undefined): string[] {\n\tif (!folders?.length) return [];\n\n\tconst sanitized = new Set<string>();\n\tfor (const folder of folders) {\n\t\tif (isAbsolute(folder) || /^[\\\\/]/.test(folder)) continue;\n\n\t\tconst segments = folder.split(/[\\\\/]/).filter(s => s && s !== '.');\n\t\tif (\n\t\t\t!segments.length ||\n\t\t\tsegments[0].toLowerCase() === 'worktrees' ||\n\t\t\tsegments.some(s => s === '..' || /[*?[\\]{}()|!:]/.test(s))\n\t\t) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tsanitized.add(segments.join('/'));\n\t}\n\treturn [...sanitized];\n}\n\n/**\n * The registered folders a `.git` watcher over the common git dir may leave unwatched: those of\n * {@link sanitizeIgnoredWorktreeFolders} that share no top-level directory with anything the `.git` globs read, which an\n * exclude would hide. Such a folder's worktrees are still ignored, only watched.\n */\nexport function getIgnoredWorktreeFolderExcludes(folders: readonly string[] | undefined): string[] {\n\treturn sanitizeIgnoredWorktreeFolders(folders).filter(f => !watchedGitDirNameRegex.test(f.split('/')[0]));\n}\n\n/**\n * Paths to leave unwatched in the working tree (relative to it), for a provider that prunes natively —\n * the same ones {@link shouldIgnoreWorkingTreePath} drops from events.\n */\nexport const workingTreeExcludes: readonly string[] = ['**/node_modules', '**/.git', '**/.watchman-cookie-*'];\n\n/** Glob for watching .gitignore files in the working tree */\nexport const gitIgnoreGlob = '.gitignore';\n\n/** Glob for detecting .git directory creation (repository init/clone) */\nexport const gitInitGlob = '**/.git';\n\n// Regex-based filters that complement the globs above. The globs tell\n// the watcher *what* to observe; these filters tell it what to *skip*\n// at runtime (transient lock files, daemon artifacts, etc.).\n\nconst ignoredRepoPathRegex = /(?:\\/|\\\\)fsmonitor--daemon(?:\\/|\\\\)|(?:^|\\/)index\\.lock$/;\n\n/**\n * Returns true if the `.git`-relative path should be ignored\n * (transient filesystem artifacts, not meaningful git state changes).\n */\nexport function shouldIgnoreRepoPath(relativePath: string): boolean {\n\treturn ignoredRepoPathRegex.test(relativePath);\n}\n\n// Anchored to a whole path segment (the lookbehind accepts the start or a separator, which also lets a scan begin\n// mid-string at the first segment after a root), so `repo.git/` or `my_node_modules/` don't match. Global so\n// `lastIndex` can start the scan past the root.\nconst ignoredWorkingTreePathRegex = /(?<![^\\\\/])(?:(?:node_modules|\\.git)(?:[\\\\/]|$)|\\.watchman-cookie-)/g;\n\nfunction isIgnoredWorkingTreePathFrom(path: string, from: number): boolean {\n\tignoredWorkingTreePathRegex.lastIndex = from;\n\treturn ignoredWorkingTreePathRegex.test(path);\n}\n\n/**\n * Returns true if the working tree path, relative to the repository root, should be ignored\n * (node_modules, .git internals, watchman cookies). Only whole segments match.\n */\nexport function shouldIgnoreWorkingTreePath(relativePath: string): boolean {\n\treturn isIgnoredWorkingTreePathFrom(relativePath, 0);\n}\n\n/**\n * Creates the per-event noise check for a working-tree watcher. It judges only the part of an absolute event path\n * inside `repoPath`, so folders above the root (`app.git/feature`, a `node_modules` ancestor) never count. The root is\n * compiled once here, so an event costs one anchored match and a scan of its tail, with no path normalization. The\n * match is tolerant of either separator and, off Linux, of case, as `isDescendant` is.\n *\n * A path not under the root is judged whole.\n */\nexport function createWorkingTreeNoiseFilter(repoPath: string): (absoluteEventPath: string) => boolean {\n\tconst root = getBestPath(repoPath);\n\tconst source = root.split('/').map(escapeRegex).join('[\\\\\\\\/]');\n\t// Sticky: the match must start at `lastIndex` (0), so it is a prefix test with no scan\n\tconst rootRegex = new RegExp(\n\t\t`${root.startsWith('/') ? '' : '[\\\\\\\\/]?'}${source}(?:[\\\\\\\\/]|$)`,\n\t\tisLinux ? 'y' : 'iy',\n\t);\n\n\treturn (absoluteEventPath: string): boolean => {\n\t\trootRegex.lastIndex = 0;\n\t\treturn isIgnoredWorkingTreePathFrom(\n\t\t\tabsoluteEventPath,\n\t\t\trootRegex.test(absoluteEventPath) ? rootRegex.lastIndex : 0,\n\t\t);\n\t};\n}\n"],"mappings":";;;;AASA,MAAM,cACL;AAYD,MAAM,oBAAoB;;AAG1B,MAAa,qBAAqB,IAAI,YAAY,GAAG,kBAAkB;;AAGvE,MAAa,iBAAiB,IAAI,YAAY;;AAG9C,MAAa,mBAAmB,IAAI,kBAAkB;AAEtD,MAAM,wBAAwB,IAAI,OACjC,OAAO,kBACL,MAAM,GAAG,CAAC,CACV,KAAI,MACJ,EACE,QAAQ,sBAAsB,MAAM,CAAC,CACrC,QAAQ,gBAAe,SAAS,SAAS,MAAM,UAAU,UAAW,CACvE,CAAC,CACA,KAAK,GAAG,EAAE,GACb;;;;;AAMA,SAAgB,mBAAm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CAAiC,SAAkD;CAClG,OAAO,+BAA+B,OAAO,CAAC,CAAC,QAAO,MAAK,CAAC,uBAAuB,KAAK,EAAE,MAAM,GAAG,CAAC,CAAC,EAAE,CAAC;AACzG;;;;;AAMA,MAAa,sBAAyC;CAAC;CAAmB;CAAW;AAAuB;;AAG5G,MAAa,gBAAgB;;AAG7B,MAAa,cAAc;AAM3B,MAAM,uBAAuB;;;;;AAM7B,SAAgB,qBAAqB,cAA+B;CACnE,OAAO,qBAAqB,KAAK,YAAY;AAC9C;AAKA,MAAM,8BAA8B;AAEpC,SAAS,6BAA6B,MAAc,MAAuB;CAC1E,4BAA4B,YAAY;CACxC,OAAO,4BAA4B,KAAK,IAAI;AAC7C;;;;;AAMA,SAAgB,4BAA4B,cAA+B;CAC1E,OAAO,6BAA6B,cAAc,CAAC;AACpD;;;;;;;;;AAUA,SAAgB,6BAA6B,UAA0D;CACtG,MAAM,OAAO,YAAY,QAAQ;CACjC,MAAM,SAAS,KAAK,MAAM,GAAG,CAAC,CAAC,IAAI,WAAW,CAAC,CAAC,KAAK,SAAS;CAE9D,MAAM,YAAY,IAAI,OACrB,GAAG,KAAK,WAAW,GAAG,IAAI,KAAK,aAAa,OAAO,gBACnD,UAAU,MAAM,IACjB;CAEA,QAAQ,sBAAuC;EAC9C,UAAU,YAAY;EACtB,OAAO,6BACN,mBACA,UAAU,KAAK,iBAAiB,IAAI,UAAU,YAAY,CAC3D;CACD;AACD"}
|
|
1
|
+
{"version":3,"file":"watcherPatterns.js","names":[],"sources":["../../../../git/src/watching/watcherPatterns.ts"],"sourcesContent":["import { getBestPath, isAbsolute } from '@gitlens/utils/path.js';\nimport { isLinux, isWindows } from '@gitlens/utils/platform.js';\nimport { escapeRegex } from '@gitlens/utils/string.js';\nimport type { GitDirProbe } from './gitDirPoller.js';\n\n// Glob patterns for watching files inside the .git directory.\n// They represent pure Git knowledge — the library owns these patterns and\n// provides them to the pluggable FileWatcherFactory.\n\nconst dotGitFiles =\n\t'index,HEAD,*_HEAD,MERGE_*,rebase-apply,rebase-apply/**,rebase-merge,rebase-merge/**,sequencer,sequencer/**';\n\n// `worktrees` (the bare entry, no `/*` suffix) is its own pattern: `worktree remove` deletes the whole\n// `worktrees/<id>` subtree in one syscall, and some platforms/watcher backends coalesce a same-instant\n// subtree delete into a single event for the PARENT directory — `worktrees/*` alone never matches that.\n// `classifyGitDirChange` classifies a bare `worktrees` path, so this is watch-coverage only.\n//\n// Only what `git worktree list` reports per worktree is watched here (its HEAD, lock and location). A\n// linked worktree's own index, `*_HEAD`, `MERGE_*`, rebase and sequencer state is watched by that\n// worktree's root watcher (`dotGitGlobRoot`) instead, so it never wakes sibling worktrees.\nconst dotGitWorktreeFiles = 'worktrees,worktrees/*,worktrees/*/HEAD,worktrees/*/locked,worktrees/*/gitdir';\n\nconst dotGitCommonFiles = `config,gk/config,refs/**,packed-refs,shallow,info/exclude,FETCH_HEAD,${dotGitWorktreeFiles}`;\n\n/** For a checkout whose `.git` directory is the common one (a standard repo or a main checkout): every .git file */\nexport const dotGitGlobCombined = `{${dotGitFiles},${dotGitCommonFiles}}`;\n\n/** For worktree repos: root watcher (worktree-specific files only) */\nexport const dotGitGlobRoot = `{${dotGitFiles}}`;\n\n/** For worktree repos: common watcher (shared config, refs, info, etc.) */\nexport const dotGitGlobCommon = `{${dotGitCommonFiles}}`;\n\nconst dotGitCommonPathRegex = new RegExp(\n\t`^(?:${dotGitCommonFiles\n\t\t.split(',')\n\t\t.map(p =>\n\t\t\tp\n\t\t\t\t.replace(/[.+?^${}()|[\\]\\\\]/g, '\\\\$&')\n\t\t\t\t.replace(/\\/\\*\\*$|\\*/g, glob => (glob === '*' ? '[^/]*' : '(?:/.*)?')),\n\t\t)\n\t\t.join('|')})$`,\n);\n\n/**\n * Whether a path relative to the common `.git` directory is one {@link dotGitGlobCommon} reads: a file every checkout of\n * the repository shares. A trailing `/**` takes in the directory itself, as a watcher's globstar may\n */\nexport function isGitDirCommonPath(relativePath: string): boolean {\n\treturn dotGitCommonPathRegex.test(relativePath);\n}\n\n/**\n * Paths to leave unwatched under the `.git` directory (relative to it), for a provider that prunes natively.\n * Only paths nothing in the globs above reads: never anything under `refs`, `worktrees/*` itself, `gk`, `info`,\n * or the rebase/sequencer directories.\n */\nexport const gitDirExcludes: readonly string[] = [\n\t'objects',\n\t'logs',\n\t'hooks',\n\t'lfs',\n\t'modules',\n\t'rr-cache',\n\t'fsmonitor--daemon*',\n\t'worktrees/*/logs',\n];\n\n/**\n * What a poll stats in a worktree's own `.git` directory when its watcher can't be trusted — the files\n * {@link dotGitGlobRoot} reads.\n */\nexport const gitDirRootProbes: readonly GitDirProbe[] = [\n\t{ path: 'HEAD' },\n\t{ path: 'index' },\n\t{ path: 'ORIG_HEAD' },\n\t{ path: 'MERGE_HEAD' },\n\t{ path: 'CHERRY_PICK_HEAD' },\n\t{ path: 'REVERT_HEAD' },\n\t{ path: 'REBASE_HEAD' },\n\t{ path: 'rebase-merge' },\n\t{ path: 'rebase-apply' },\n\t{ path: 'sequencer' },\n\t// Moves with every commit, reset or checkout on the checked-out branch, without the poll knowing its name\n\t{ path: 'logs/HEAD', emitAs: ['HEAD'] },\n];\n\n/**\n * What a poll stats in the common `.git` directory — the files {@link dotGitGlobCommon} reads, with the `refs/**` it\n * can't list narrowed to its namespace directories (whose mtime moves as a top-level ref is created or deleted) and\n * to the named refs of {@link getGitDirRefProbes}.\n */\nexport const gitDirCommonProbes: readonly GitDirProbe[] = [\n\t{ path: 'packed-refs' },\n\t{ path: 'config' },\n\t{ path: 'gk/config' },\n\t{ path: 'info/exclude' },\n\t{ path: 'refs/heads' },\n\t// Moves as a remote's directory appears or goes: `git remote remove` and `git remote rename` delete or move each of\n\t// its loose refs (a packed one is locked through a loose path too), and git removes the emptied directory. Reported\n\t// as every remote-tracking ref possibly moved, since the poll can't tell which remote it was. A remote whose name\n\t// nests under a directory another remote still uses (`foo/bar` beside `foo/baz`) leaves it unmoved, so only a named\n\t// ref's probe sees that one go\n\t{ path: 'refs/remotes' },\n\t{ path: 'refs/tags' },\n\t{ path: 'refs/stash' },\n\t{ path: 'worktrees' },\n\t{ path: 'shallow' },\n\t// A fetch writes it with the remote-tracking refs it updated, which the poll can't list. Git rewrites it even on a\n\t// fetch that moves nothing, so each fetch is reported as a `remotes` change: the cost of seeing remote-tracking\n\t// refs no subscriber names\n\t{ path: 'FETCH_HEAD', emitAs: ['FETCH_HEAD', 'refs/remotes'] },\n];\n\n/** For each path a probe of {@link gitDirRootProbes} or {@link gitDirCommonProbes} is emitted as, the probes emitted as it */\nexport const gitDirProbesByEmittedPath: ReadonlyMap<string, readonly string[]> = getProbesByEmittedPath([\n\t...gitDirRootProbes,\n\t...gitDirCommonProbes,\n]);\n\nfunction getProbesByEmittedPath(probes: readonly GitDirProbe[]): Map<string, string[]> {\n\tconst map = new Map<string, string[]>();\n\tfor (const probe of probes) {\n\t\tfor (const path of probe.emitAs ?? []) {\n\t\t\tconst paths = map.get(path);\n\t\t\tif (paths == null) {\n\t\t\t\tmap.set(path, [probe.path]);\n\t\t\t} else {\n\t\t\t\tpaths.push(probe.path);\n\t\t\t}\n\t\t}\n\t}\n\treturn map;\n}\n\n/**\n * Probes for named branches and remote-tracking refs: each loose ref file, and each directory between it and its\n * namespace (`refs/heads/feature` for `refs/heads/feature/x`, `refs/remotes/origin`), whose mtime moves as a sibling\n * ref is created or deleted. A ref created in a directory no named ref sits in is left to `packed-refs`, `logs/HEAD`\n * and `FETCH_HEAD`.\n */\nexport function getGitDirRefProbes(refs: Iterable<string>): GitDirProbe[] {\n\tconst paths = new Set<string>();\n\tfor (const ref of refs) {\n\t\tconst namespaceEnd = ref.startsWith('refs/heads/') ? 10 : ref.startsWith('refs/remotes/') ? 12 : -1;\n\t\tif (namespaceEnd === -1) continue;\n\n\t\tfor (let path = ref; path.length > namespaceEnd; path = path.substring(0, path.lastIndexOf('/'))) {\n\t\t\tpaths.add(path);\n\t\t}\n\t}\n\treturn Array.from(paths, path => ({ path: path }));\n}\n\n/**\n * The top-level names under the `.git` directory that the globs above read or a poll stats, as one case-insensitive\n * pattern (a folder may sit on a case-insensitive file system)\n */\nconst watchedGitDirNames = new Set(\n\t[\n\t\t...`${dotGitFiles},${dotGitCommonFiles}`.split(','),\n\t\t...gitDirRootProbes.map(p => p.path),\n\t\t...gitDirCommonProbes.map(p => p.path),\n\t].map(p => p.split('/')[0]),\n);\nconst watchedGitDirNameRegex = new RegExp(\n\t`^(?:${Array.from(watchedGitDirNames, name => name.replace(/[.+?^${}()|[\\]\\\\]/g, '\\\\$&').replace(/\\*/g, '[^/]*')).join('|')})$`,\n\t'i',\n);\n\n/**\n * The registered folders whose worktrees core ignores, each as a `/`-separated literal path relative to a repository's\n * common git dir, without `.` or empty segments; any other is dropped. A folder must lie strictly inside the common git\n * dir (never absolute, never through `..`), name no glob syntax (a picomatch group or extglob's parentheses and `|`\n * included) or `:` (a watcher's exclude would read it as a pattern, so `(refs|x)` would leave `refs` unwatched, or a\n * drive), and not lie under `worktrees`, whose admin entries are what tells an ignored worktree apart.\n */\nexport function sanitizeIgnoredWorktreeFolders(folders: readonly string[] | undefined): string[] {\n\tif (!folders?.length) return [];\n\n\tconst sanitized = new Set<string>();\n\tfor (const folder of folders) {\n\t\tif (isAbsolute(folder) || /^[\\\\/]/.test(folder)) continue;\n\n\t\tconst segments = folder.split(/[\\\\/]/).filter(s => s && s !== '.');\n\t\tif (\n\t\t\t!segments.length ||\n\t\t\tsegments[0].toLowerCase() === 'worktrees' ||\n\t\t\tsegments.some(s => s === '..' || /[*?[\\]{}()|!:]/.test(s))\n\t\t) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tsanitized.add(segments.join('/'));\n\t}\n\treturn [...sanitized];\n}\n\n/**\n * The registered folders a `.git` watcher over the common git dir may leave unwatched: those of\n * {@link sanitizeIgnoredWorktreeFolders} that share no top-level directory with anything the `.git` globs read, which an\n * exclude would hide. Such a folder's worktrees are still ignored, only watched.\n */\nexport function getIgnoredWorktreeFolderExcludes(folders: readonly string[] | undefined): string[] {\n\treturn sanitizeIgnoredWorktreeFolders(folders).filter(f => !watchedGitDirNameRegex.test(f.split('/')[0]));\n}\n\n/**\n * Paths to leave unwatched in the working tree (relative to it), for a provider that prunes natively —\n * the same ones {@link shouldIgnoreWorkingTreePath} drops from events.\n */\nexport const workingTreeExcludes: readonly string[] = ['**/node_modules', '**/.git', '**/.watchman-cookie-*'];\n\n/** Glob for watching .gitignore files in the working tree */\nexport const gitIgnoreGlob = '.gitignore';\n\n/** Glob for detecting .git directory creation (repository init/clone) */\nexport const gitInitGlob = '**/.git';\n\n// Regex-based filters that complement the globs above. The globs tell\n// the watcher *what* to observe; these filters tell it what to *skip*\n// at runtime (transient lock files, daemon artifacts, etc.).\n\nconst ignoredRepoPathRegex = /(?:\\/|\\\\)fsmonitor--daemon(?:\\/|\\\\)|(?:^|\\/)index\\.lock$/;\n\n/**\n * Returns true if the `.git`-relative path should be ignored\n * (transient filesystem artifacts, not meaningful git state changes).\n */\nexport function shouldIgnoreRepoPath(relativePath: string): boolean {\n\treturn ignoredRepoPathRegex.test(relativePath);\n}\n\n// Anchored to a whole path segment (the lookbehind accepts the start or a separator, which also lets a scan begin\n// mid-string at the first segment after a root), so `repo.git/` or `my_node_modules/` don't match. Global so\n// `lastIndex` can start the scan past the root.\nconst ignoredWorkingTreePathRegex = /(?<![^\\\\/])(?:(?:node_modules|\\.git)(?:[\\\\/]|$)|\\.watchman-cookie-)/g;\n\nconst ignoredPosixWorkingTreePathRegex = /(?<![^/])(?:(?:node_modules|\\.git)(?:\\/|$)|\\.watchman-cookie-)/g;\n\nfunction isIgnoredWorkingTreePathFrom(path: string, from: number, pattern = ignoredWorkingTreePathRegex): boolean {\n\tpattern.lastIndex = from;\n\treturn pattern.test(path);\n}\n\n/**\n * Returns true if the working tree path, relative to the repository root, should be ignored\n * (node_modules, .git internals, watchman cookies). Only whole segments match.\n */\nexport function shouldIgnoreWorkingTreePath(relativePath: string): boolean {\n\treturn isIgnoredWorkingTreePathFrom(relativePath, 0);\n}\n\n/**\n * Creates the per-event noise check for a working-tree watcher. It judges only the part of an absolute event path\n * inside `repoPath`, so folders above the root (`app.git/feature`, a `node_modules` ancestor) never count. The root is\n * compiled once here, so an event costs one anchored match and a scan of its tail, with no path normalization. The\n * match uses POSIX separators for absolute POSIX paths and tolerates case differences off Linux.\n *\n * A path not under the root is judged whole.\n */\nexport function createWorkingTreeNoiseFilter(repoPath: string): (absoluteEventPath: string) => boolean {\n\tconst posixRoot =\n\t\t!isWindows && repoPath.startsWith('/')\n\t\t\t? new RegExp(`${escapeRegex(repoPath.replace(/\\/$/, ''))}(?:/|$)`, isLinux ? 'y' : 'iy')\n\t\t\t: undefined;\n\tconst root = getBestPath(repoPath);\n\tconst source = root.split('/').map(escapeRegex).join('[\\\\\\\\/]');\n\t// Sticky: the match must start at `lastIndex` (0), so it is a prefix test with no scan\n\tconst rootRegex = new RegExp(\n\t\t`${root.startsWith('/') ? '' : '[\\\\\\\\/]?'}${source}(?:[\\\\\\\\/]|$)`,\n\t\tisLinux ? 'y' : 'iy',\n\t);\n\n\treturn (absoluteEventPath: string): boolean => {\n\t\tif (posixRoot != null && absoluteEventPath.startsWith('/')) {\n\t\t\tposixRoot.lastIndex = 0;\n\t\t\tconst from = posixRoot.test(absoluteEventPath) ? posixRoot.lastIndex : 0;\n\t\t\treturn isIgnoredWorkingTreePathFrom(absoluteEventPath, from, ignoredPosixWorkingTreePathRegex);\n\t\t}\n\n\t\trootRegex.lastIndex = 0;\n\t\treturn isIgnoredWorkingTreePathFrom(\n\t\t\tabsoluteEventPath,\n\t\t\trootRegex.test(absoluteEventPath) ? rootRegex.lastIndex : 0,\n\t\t);\n\t};\n}\n"],"mappings":";;;;AASA,MAAM,cACL;AAYD,MAAM,oBAAoB;;AAG1B,MAAa,qBAAqB,IAAI,YAAY,GAAG,kBAAkB;;AAGvE,MAAa,iBAAiB,IAAI,YAAY;;AAG9C,MAAa,mBAAmB,IAAI,kBAAkB;AAEtD,MAAM,wBA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,GAAG;GAC3D,UAAU,YAAY;GAEtB,OAAO,6BAA6B,mBADvB,UAAU,KAAK,iBAAiB,IAAI,UAAU,YAAY,GACV,gCAAgC;EAC9F;EAEA,UAAU,YAAY;EACtB,OAAO,6BACN,mBACA,UAAU,KAAK,iBAAiB,IAAI,UAAU,YAAY,CAC3D;CACD;AACD"}
|
|
@@ -110,6 +110,7 @@ export declare class CliGitProvider implements GitProvider {
|
|
|
110
110
|
private readonly _ignoredWorktreeFolders;
|
|
111
111
|
/** By common git dir, the folders whose worktrees are ignored there: a common git dir never moves while it is open */
|
|
112
112
|
private readonly _ignoredWorktreeRoots;
|
|
113
|
+
private readonly _configWatchPaths;
|
|
113
114
|
private readonly _indexRefresher;
|
|
114
115
|
private readonly _unregisterListener;
|
|
115
116
|
private readonly _resetListener;
|
|
@@ -287,6 +288,7 @@ export declare class CliGitProvider implements GitProvider {
|
|
|
287
288
|
getIgnoredUrisFilter(repoPath: string): Promise<(uri: Uri) => boolean>;
|
|
288
289
|
getLastFetchedTimestamp(repoPath: string): Promise<number | undefined>;
|
|
289
290
|
getIgnoreFilter(repoPath: string): GitIgnoreFilter;
|
|
291
|
+
private getConfigWatchPaths;
|
|
290
292
|
getGitIgnoreWatchInputs(repoPath: string, gitDir: GitDir, options?: {
|
|
291
293
|
refreshConfig?: boolean;
|
|
292
294
|
}): Promise<GitIgnoreWatchInputs | undefined>;
|
|
@@ -301,15 +303,10 @@ export declare class CliGitProvider implements GitProvider {
|
|
|
301
303
|
* follows fails too.
|
|
302
304
|
*/
|
|
303
305
|
private getIgnoredScopes;
|
|
304
|
-
/**
|
|
305
|
-
* `check-ignore` dies on the first path it can't answer (inside a submodule, beyond a symlink, outside the repository,
|
|
306
|
-
* or empty), where this repository ignores nothing, having answered every path before it, so the paths after it are
|
|
307
|
-
* asked again, less those in the folder of a path refused for a symlink or submodule, which share its fate. Each path
|
|
308
|
-
* is answered once, in one run plus one for each refusal. Any other failure is thrown.
|
|
309
|
-
*/
|
|
310
306
|
getIgnoredPaths(repoPath: string, paths: readonly string[], options?: {
|
|
311
307
|
priority?: GitCommandPriority;
|
|
312
308
|
}, cancellation?: AbortSignal): Promise<Set<string>>;
|
|
309
|
+
private collectIgnoredPaths;
|
|
313
310
|
/**
|
|
314
311
|
* One `check-ignore` run over `paths`, adding the ignored ones to `ignored`. Returns the path git died on, which
|
|
315
312
|
* every path before it was answered ahead of, or `undefined` when all were answered.
|