@@ -33,9 +33,11 @@ import type { GitDir } from '../../../git/gitProvider';
3333import type { GitDiffFilter } from '../../../git/models/diff' ;
3434import { parseGitRemoteUrl } from '../../../git/parsers/remoteParser' ;
3535import { isUncommitted , isUncommittedStaged , shortenRevision } from '../../../git/utils/revision.utils' ;
36+ import { getCancellationTokenId } from '../../../system/-webview/cancellation' ;
3637import { configuration } from '../../../system/-webview/configuration' ;
3738import { splitPath } from '../../../system/-webview/path' ;
3839import { getHostEditorCommand } from '../../../system/-webview/vscode' ;
40+ import { getScopedCounter } from '../../../system/counter' ;
3941import { log } from '../../../system/decorators/log' ;
4042import { Logger } from '../../../system/logger' ;
4143import { slowCallWarningThreshold } from '../../../system/logger.constants' ;
@@ -165,13 +167,7 @@ function defaultExceptionHandler(ex: Error, cwd: string | undefined, start?: [nu
165167 throw ex ;
166168}
167169
168- let _uniqueCounterForStdin = 0 ;
169- function getStdinUniqueKey ( ) : number {
170- if ( _uniqueCounterForStdin === Number . MAX_SAFE_INTEGER ) {
171- _uniqueCounterForStdin = 0 ;
172- }
173- return _uniqueCounterForStdin ++ ;
174- }
170+ const uniqueCounterForStdin = getScopedCounter ( ) ;
175171
176172type ExitCodeOnlyGitCommandOptions = GitCommandOptions & { exitCodeOnly : true } ;
177173export type PushForceOptions = { withLease : true ; ifIncludes ?: boolean } | { withLease : false ; ifIncludes ?: never } ;
@@ -277,12 +273,12 @@ export class Git {
277273
278274 const gitCommand = `[${ runOpts . cwd } ] git ${ runArgs . join ( ' ' ) } ` ;
279275
280- const command = `${ correlationKey !== undefined ? `${ correlationKey } :` : '' } ${
281- options ?. stdin != null ? `${ getStdinUniqueKey ( ) } :` : ''
282- } ${ gitCommand } `;
276+ const cacheKey = `${ correlationKey !== undefined ? `${ correlationKey } :` : '' } ${
277+ options ?. stdin != null ? `${ uniqueCounterForStdin . next ( ) } :` : ''
278+ } ${ cancellation != null ? ` ${ getCancellationTokenId ( cancellation ) } :` : '' } ${ gitCommand } `;
283279
284280 let waiting ;
285- let promise = this . pendingCommands . get ( command ) ;
281+ let promise = this . pendingCommands . get ( cacheKey ) ;
286282 if ( promise == null ) {
287283 waiting = false ;
288284
@@ -309,11 +305,11 @@ export class Git {
309305 }
310306
311307 promise = runSpawn < T > ( await this . path ( ) , runArgs , encoding ?? 'utf8' , runOpts ) . finally ( ( ) => {
312- this . pendingCommands . delete ( command ) ;
308+ this . pendingCommands . delete ( cacheKey ) ;
313309 void disposeCancellation ?. dispose ( ) ;
314310 } ) ;
315311
316- this . pendingCommands . set ( command , promise ) ;
312+ this . pendingCommands . set ( cacheKey , promise ) ;
317313 } else {
318314 waiting = true ;
319315 Logger . debug ( `${ getLoggableScopeBlockOverride ( 'GIT' ) } ${ gitCommand } ${ GlyphChars . Dot } waiting...` ) ;
0 commit comments