MCPcopy
hub / github.com/claude-code-best/claude-code / start

Method start

src/utils/git/gitFilesystem.ts:353–380  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

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