@@ -219,7 +219,7 @@ export class GitService extends Disposable {
219219 if ( ! this . UseCaching ) return ;
220220 if ( document . uri . scheme !== DocumentSchemes . File ) return ;
221221
222- const cacheKey = this . getCacheEntryKey ( document . fileName ) ;
222+ const cacheKey = this . getCacheEntryKey ( document . uri ) ;
223223
224224 if ( reason === RemoveCacheReason . DocumentSaved ) {
225225 // Don't remove broken blame on save (since otherwise we'll have to run the broken blame again)
@@ -313,7 +313,7 @@ export class GitService extends Disposable {
313313 public async getBlameability ( uri : GitUri ) : Promise < boolean > {
314314 if ( ! this . UseCaching ) return await this . isTracked ( uri ) ;
315315
316- const cacheKey = this . getCacheEntryKey ( uri . fsPath ) ;
316+ const cacheKey = this . getCacheEntryKey ( uri ) ;
317317 const entry = this . _gitCache . get ( cacheKey ) ;
318318 if ( entry === undefined ) return await this . isTracked ( uri ) ;
319319
@@ -326,11 +326,9 @@ export class GitService extends Disposable {
326326 key += `:${ uri . sha } ` ;
327327 }
328328
329- const fileName = uri . fsPath ;
330-
331329 let entry : GitCacheEntry | undefined ;
332330 if ( this . UseCaching ) {
333- const cacheKey = this . getCacheEntryKey ( fileName ) ;
331+ const cacheKey = this . getCacheEntryKey ( uri ) ;
334332 entry = this . _gitCache . get ( cacheKey ) ;
335333
336334 if ( entry !== undefined ) {
@@ -352,7 +350,7 @@ export class GitService extends Disposable {
352350 Logger . log ( `getBlameForFile('${ uri . repoPath } ', '${ uri . fsPath } ', ${ uri . sha } )` ) ;
353351 }
354352
355- const promise = this . _getBlameForFile ( uri , fileName , entry , key ) ;
353+ const promise = this . _getBlameForFile ( uri , entry , key ) ;
356354
357355 if ( entry ) {
358356 Logger . log ( `Add blame cache for '${ entry . key } :${ key } '` ) ;
@@ -365,12 +363,12 @@ export class GitService extends Disposable {
365363 return promise ;
366364 }
367365
368- private async _getBlameForFile ( uri : GitUri , fileName : string , entry : GitCacheEntry | undefined , key : string ) : Promise < IGitBlame | undefined > {
369- const [ file , root ] = Git . splitPath ( fileName , uri . repoPath , false ) ;
366+ private async _getBlameForFile ( uri : GitUri , entry : GitCacheEntry | undefined , key : string ) : Promise < IGitBlame | undefined > {
367+ const [ file , root ] = Git . splitPath ( uri . fsPath , uri . repoPath , false ) ;
370368
371369 const ignore = await this . _gitignore ;
372370 if ( ignore && ! ignore . filter ( [ file ] ) . length ) {
373- Logger . log ( `Skipping blame; '${ fileName } ' is gitignored` ) ;
371+ Logger . log ( `Skipping blame; '${ uri . fsPath } ' is gitignored` ) ;
374372 if ( entry && entry . key ) {
375373 this . _onDidBlameFail . fire ( entry . key ) ;
376374 }
@@ -537,8 +535,10 @@ export class GitService extends Disposable {
537535 return branches ;
538536 }
539537
540- getCacheEntryKey ( fileName : string ) {
541- return Git . normalizePath ( fileName ) . toLowerCase ( ) ;
538+ getCacheEntryKey ( fileName : string ) : string ;
539+ getCacheEntryKey ( uri : Uri ) : string ;
540+ getCacheEntryKey ( fileNameOrUri : string | Uri ) : string {
541+ return Git . normalizePath ( typeof fileNameOrUri === 'string' ? fileNameOrUri : fileNameOrUri . fsPath ) . toLowerCase ( ) ;
542542 }
543543
544544 async getConfig ( key : string , repoPath ?: string ) : Promise < string > {
@@ -547,13 +547,13 @@ export class GitService extends Disposable {
547547 return await Git . config_get ( key , repoPath ) ;
548548 }
549549
550- getGitUriForFile ( fileName : string ) {
551- const cacheKey = this . getCacheEntryKey ( fileName ) ;
550+ getGitUriForFile ( uri : Uri ) {
551+ const cacheKey = this . getCacheEntryKey ( uri ) ;
552552 const entry = this . _uriCache . get ( cacheKey ) ;
553553 return entry && entry . uri ;
554554 }
555555
556- async getDiffForFile ( repoPath : string | undefined , fileName : string , sha1 ?: string , sha2 ?: string ) : Promise < IGitDiff | undefined > {
556+ async getDiffForFile ( uri : GitUri , sha1 ?: string , sha2 ?: string ) : Promise < IGitDiff | undefined > {
557557 let key = 'diff' ;
558558 if ( sha1 !== undefined ) {
559559 key += `:${ sha1 } ` ;
@@ -564,29 +564,29 @@ export class GitService extends Disposable {
564564
565565 let entry : GitCacheEntry | undefined ;
566566 if ( this . UseCaching ) {
567- const cacheKey = this . getCacheEntryKey ( fileName ) ;
567+ const cacheKey = this . getCacheEntryKey ( uri ) ;
568568 entry = this . _gitCache . get ( cacheKey ) ;
569569
570570 if ( entry !== undefined ) {
571571 const cachedDiff = entry . get < ICachedDiff > ( key ) ;
572572 if ( cachedDiff !== undefined ) {
573- Logger . log ( `Cached(${ key } ): getDiffForFile('${ repoPath } ', '${ fileName } ', ${ sha1 } , ${ sha2 } )` ) ;
573+ Logger . log ( `Cached(${ key } ): getDiffForFile('${ uri . repoPath } ', '${ uri . fsPath } ', ${ sha1 } , ${ sha2 } )` ) ;
574574 return cachedDiff . item ;
575575 }
576576 }
577577
578- Logger . log ( `Not Cached(${ key } ): getDiffForFile('${ repoPath } ', '${ fileName } ', ${ sha1 } , ${ sha2 } )` ) ;
578+ Logger . log ( `Not Cached(${ key } ): getDiffForFile('${ uri . repoPath } ', '${ uri . fsPath } ', ${ sha1 } , ${ sha2 } )` ) ;
579579
580580 if ( entry === undefined ) {
581581 entry = new GitCacheEntry ( cacheKey ) ;
582582 this . _gitCache . set ( entry . key , entry ) ;
583583 }
584584 }
585585 else {
586- Logger . log ( `getDiffForFile('${ repoPath } ', '${ fileName } ', ${ sha1 } , ${ sha2 } )` ) ;
586+ Logger . log ( `getDiffForFile('${ uri . repoPath } ', '${ uri . fsPath } ', ${ sha1 } , ${ sha2 } )` ) ;
587587 }
588588
589- const promise = this . _getDiffForFile ( repoPath , fileName , sha1 , sha2 , entry , key ) ;
589+ const promise = this . _getDiffForFile ( uri . repoPath , uri . fsPath , sha1 , sha2 , entry , key ) ;
590590
591591 if ( entry ) {
592592 Logger . log ( `Add log cache for '${ entry . key } :${ key } '` ) ;
@@ -624,9 +624,9 @@ export class GitService extends Disposable {
624624 }
625625 }
626626
627- async getDiffForLine ( repoPath : string | undefined , fileName : string , line : number , sha1 ?: string , sha2 ?: string ) : Promise < [ string | undefined , string | undefined ] | undefined > {
627+ async getDiffForLine ( uri : GitUri , line : number , sha1 ?: string , sha2 ?: string ) : Promise < [ string | undefined , string | undefined ] | undefined > {
628628 try {
629- const diff = await this . getDiffForFile ( repoPath , fileName , sha1 , sha2 ) ;
629+ const diff = await this . getDiffForFile ( uri , sha1 , sha2 ) ;
630630 if ( diff === undefined ) return undefined ;
631631
632632 const chunk = diff . chunks . find ( _ => Math . min ( _ . originalStart , _ . changesStart ) <= line && Math . max ( _ . originalEnd , _ . changesEnd ) >= line ) ;
@@ -913,19 +913,10 @@ export class GitService extends Disposable {
913913 return Git . show ( repoPath , fileName , sha ) ;
914914 }
915915
916- hasGitUriForFile ( editor : TextEditor ) : boolean ;
917- hasGitUriForFile ( fileName : string ) : boolean ;
918- hasGitUriForFile ( fileNameOrEditor : string | TextEditor ) : boolean {
919- let fileName : string ;
920- if ( typeof fileNameOrEditor === 'string' ) {
921- fileName = fileNameOrEditor ;
922- }
923- else {
924- if ( ! fileNameOrEditor || ! fileNameOrEditor . document || ! fileNameOrEditor . document . uri ) return false ;
925- fileName = fileNameOrEditor . document . uri . fsPath ;
926- }
916+ hasGitUriForFile ( editor : TextEditor ) : boolean {
917+ if ( editor === undefined || editor . document === undefined || editor . document . uri === undefined ) return false ;
927918
928- const cacheKey = this . getCacheEntryKey ( fileName ) ;
919+ const cacheKey = this . getCacheEntryKey ( editor . document . uri ) ;
929920 return this . _uriCache . has ( cacheKey ) ;
930921 }
931922
0 commit comments