@@ -494,27 +494,27 @@ export class StatusGitSubProvider implements GitStatusSubProvider {
494
494
@gate ( )
495
495
@log ( )
496
496
async getStatusForFile ( repoPath : string , pathOrUri : string | Uri ) : Promise < GitStatusFile | undefined > {
497
- const status = await this . getStatus ( repoPath ) ;
498
- if ( ! status ?. files . length ) return undefined ;
499
-
500
- const [ relativePath ] = splitPath ( pathOrUri , repoPath ) ;
501
- const file = status . files . find ( f => f . path === relativePath ) ;
502
- return file ;
497
+ const files = await this . getStatusForFiles ( repoPath , pathOrUri ) ;
498
+ return files ?. [ 0 ] ;
503
499
}
504
500
505
501
@gate ( )
506
502
@log ( )
507
- async getStatusForFiles ( repoPath : string , pathOrGlob : Uri ) : Promise < GitStatusFile [ ] | undefined > {
508
- let [ relativePath ] = splitPath ( pathOrGlob , repoPath ) ;
509
- if ( ! relativePath . endsWith ( '/*' ) ) {
510
- return this . getStatusForFile ( repoPath , pathOrGlob ) . then ( f => ( f != null ? [ f ] : undefined ) ) ;
511
- }
503
+ async getStatusForFiles ( repoPath : string , pathOrGlob : string | Uri ) : Promise < GitStatusFile [ ] | undefined > {
504
+ const [ relativePath ] = splitPath ( pathOrGlob , repoPath ) ;
512
505
513
- relativePath = relativePath . substring ( 0 , relativePath . length - 1 ) ;
514
- const status = await this . getStatus ( repoPath ) ;
515
- if ( ! status ?. files . length ) return undefined ;
506
+ const porcelainVersion = ( await this . git . isAtLeastVersion ( '2.11' ) ) ? 2 : 1 ;
516
507
517
- const files = status . files . filter ( f => f . path . startsWith ( relativePath ) ) ;
518
- return files ;
508
+ const data = await this . git . status (
509
+ repoPath ,
510
+ porcelainVersion ,
511
+ {
512
+ similarityThreshold : configuration . get ( 'advanced.similarityThreshold' ) ?? undefined ,
513
+ } ,
514
+ relativePath ,
515
+ ) ;
516
+
517
+ const status = parseGitStatus ( this . container , data , repoPath , porcelainVersion ) ;
518
+ return status ?. files ;
519
519
}
520
520
}
0 commit comments