diff --git a/extensions/git/src/repository.ts b/extensions/git/src/repository.ts index 6018648f468dc320b685ce8a260da50f6dfd5fe0..bec7ce5ead730febda623b5d4d6481bc4cefd557 100644 --- a/extensions/git/src/repository.ts +++ b/extensions/git/src/repository.ts @@ -488,7 +488,10 @@ class DotGitWatcher implements IFileWatcher { private transientDisposables: IDisposable[] = []; private disposables: IDisposable[] = []; - constructor(private repository: Repository) { + constructor( + private repository: Repository, + private outputChannel: OutputChannel + ) { const rootWatcher = watch(repository.dotGit); this.disposables.push(rootWatcher); @@ -511,9 +514,15 @@ class DotGitWatcher implements IFileWatcher { const { name, remote } = this.repository.HEAD.upstream; const upstreamPath = path.join(this.repository.dotGit, 'refs', 'remotes', remote, name); - const upstreamWatcher = watch(upstreamPath); - this.transientDisposables.push(upstreamWatcher); - upstreamWatcher.event(this.emitter.fire, this.emitter, this.transientDisposables); + try { + const upstreamWatcher = watch(upstreamPath); + this.transientDisposables.push(upstreamWatcher); + upstreamWatcher.event(this.emitter.fire, this.emitter, this.transientDisposables); + } catch (err) { + if (env.logLevel <= LogLevel.Info) { + this.outputChannel.appendLine(`Failed to watch ref '${upstreamPath}'. Ref is most likely packed.`); + } + } } dispose() { @@ -642,7 +651,7 @@ export class Repository implements Disposable { const onWorkspaceRepositoryFileChange = filterEvent(onWorkspaceFileChange, uri => isDescendant(repository.root, uri.fsPath)); const onWorkspaceWorkingTreeFileChange = filterEvent(onWorkspaceRepositoryFileChange, uri => !/\/\.git($|\/)/.test(uri.path)); - const dotGitFileWatcher = new DotGitWatcher(this); + const dotGitFileWatcher = new DotGitWatcher(this, outputChannel); this.disposables.push(dotGitFileWatcher); // FS changes should trigger `git status`: