MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / start

Method start

source code/utils/git/gitFilesystem.ts:355–382  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

353 }
354
355 private async start(): Promise<void> {
356 this.gitDir = await resolveGitDir()
357 this.initialized = true
358 if (!this.gitDir) {
359 return
360 }
361
362 // In a worktree, branch refs and the main config are shared and live in
363 // commonDir, not the per-worktree gitDir. Resolve once so we don't
364 // re-read the commondir file on every branch switch.
365 this.commonDir = await getCommonDir(this.gitDir)
366
367 // Watch .git/HEAD and .git/config
368 this.watchPath(join(this.gitDir, 'HEAD'), () => {
369 void this.onHeadChanged()
370 })
371 // Config (remote URLs) lives in commonDir for worktrees
372 this.watchPath(join(this.commonDir ?? this.gitDir, 'config'), () => {
373 this.invalidate()
374 })
375
376 // Watch the current branch's ref file for commit changes
377 await this.watchCurrentBranchRef()
378
379 registerCleanup(async () => {
380 this.stopWatching()
381 })
382 }
383
384 private watchPath(path: string, callback: () => void): void {
385 this.watchedPaths.push(path)

Callers 1

ensureStartedMethod · 0.95

Calls 8

watchPathMethod · 0.95
onHeadChangedMethod · 0.95
invalidateMethod · 0.95
watchCurrentBranchRefMethod · 0.95
stopWatchingMethod · 0.95
resolveGitDirFunction · 0.85
getCommonDirFunction · 0.85
registerCleanupFunction · 0.85

Tested by

no test coverage detected