Skip to content

Commit 77a463b

Browse files
committed
Avoids .gitignore watching outside repo root
For performance reasons
1 parent ccf68d6 commit 77a463b

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/git/models/repository.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,10 @@ const instanceCounter = getScopedCounter();
141141
export class Repository implements Disposable {
142142
private _onDidChange = new EventEmitter<RepositoryChangeEvent>();
143143
get onDidChange(): Event<RepositoryChangeEvent> {
144+
if (this._closed) {
145+
// Closed repositories generally won't fire change events, so we should check to make sure this is correct
146+
debugger;
147+
}
144148
return this._onDidChange.event;
145149
}
146150

@@ -165,9 +169,7 @@ export class Repository implements Disposable {
165169

166170
private _idHash: string | undefined;
167171
get idHash(): string {
168-
if (this._idHash === undefined) {
169-
this._idHash = md5(this.id);
170-
}
172+
this._idHash ??= md5(this.id);
171173
return this._idHash;
172174
}
173175

@@ -969,8 +971,8 @@ export class Repository implements Disposable {
969971

970972
const disposables: Disposable[] = [];
971973

972-
// If the repository is not part of the workspace, then limit watching to only the .gitignore file at the root of the repository
973-
const gitIgnorePattern = this.folder != null ? '**/.gitignore' : '.gitignore';
974+
// Limit watching to only the .gitignore file at the root of the repository for performance reasons
975+
const gitIgnorePattern = '.gitignore';
974976
Logger.debug(scope, `watching '${this.uri.toString(true)}/${gitIgnorePattern}' for .gitignore changes`);
975977

976978
const watcher = workspace.createFileSystemWatcher(new RelativePattern(this.uri, gitIgnorePattern));

0 commit comments

Comments
 (0)