@@ -7,6 +7,7 @@ import type { CancellationToken, Disposable, OutputChannel } from 'vscode';
77import { env , Uri , window , workspace } from 'vscode' ;
88import { hrtime } from '@env/hrtime' ;
99import { GlyphChars } from '../../../constants' ;
10+ import type { Container } from '../../../container' ;
1011import { CancellationError , isCancellationError } from '../../../errors' ;
1112import type { FilteredGitFeatures , GitFeatureOrPrefix , GitFeatures } from '../../../features' ;
1213import { gitFeaturesByVersion } from '../../../features' ;
@@ -232,10 +233,24 @@ export type GitResult<T extends string | Buffer | unknown> = {
232233 readonly cancelled ?: boolean ;
233234} ;
234235
235- export class Git {
236+ export class Git implements Disposable {
237+ private readonly _disposable : Disposable ;
236238 /** Map of running git commands -- avoids running duplicate overlaping commands */
237239 private readonly pendingCommands = new Map < string , Promise < RunResult < string | Buffer > > > ( ) ;
238240
241+ constructor ( container : Container ) {
242+ this . _disposable = container . events . on ( 'git:cache:reset' , e => {
243+ // Ignore provider resets (e.g. it needs to be git specific)
244+ if ( e . data . types ?. every ( t => t === 'providers' ) ) return ;
245+
246+ this . pendingCommands . clear ( ) ;
247+ } ) ;
248+ }
249+
250+ dispose ( ) : void {
251+ this . _disposable . dispose ( ) ;
252+ }
253+
239254 async exec (
240255 options : ExitCodeOnlyGitCommandOptions ,
241256 ...args : readonly ( string | undefined ) [ ]
0 commit comments