@@ -935,10 +935,14 @@ export class GitService extends Disposable {
935935 }
936936 }
937937
938- async getLogForFile ( repoPath : string | undefined , fileName : string , options : { maxCount ?: number , range ?: Range , ref ?: string , reverse ?: boolean , skipMerges ?: boolean } = { } ) : Promise < GitLog | undefined > {
938+ async getLogForFile ( repoPath : string | undefined , fileName : string , options : { maxCount ?: number , range ?: Range , ref ?: string , renames ?: boolean , reverse ?: boolean } = { } ) : Promise < GitLog | undefined > {
939939 if ( repoPath !== undefined && repoPath === Strings . normalizePath ( fileName ) ) throw new Error ( `File name cannot match the repository path; fileName=${ fileName } ` ) ;
940940
941- options = { reverse : false , skipMerges : false , ...options } ;
941+ options = { reverse : false , ...options } ;
942+
943+ if ( options . renames === undefined ) {
944+ options . renames = true ;
945+ }
942946
943947 let key = 'log' ;
944948 if ( options . ref !== undefined ) {
@@ -947,13 +951,16 @@ export class GitService extends Disposable {
947951 if ( options . maxCount !== undefined ) {
948952 key += `:n${ options . maxCount } ` ;
949953 }
954+ if ( options . renames ) {
955+ key += `:follow` ;
956+ }
950957
951958 const doc = await Container . tracker . getOrAdd ( new GitUri ( Uri . file ( fileName ) , { repoPath : repoPath ! , sha : options . ref } ) ) ;
952959 if ( this . UseCaching && options . range === undefined && ! options . reverse ) {
953960 if ( doc . state !== undefined ) {
954961 const cachedLog = doc . state . get < CachedLog > ( key ) ;
955962 if ( cachedLog !== undefined ) {
956- Logger . log ( `getLogForFile[Cached(${ key } )]('${ repoPath } ', '${ fileName } ', '${ options . ref } ', ${ options . maxCount } , undefined, ${ options . reverse } , ${ options . skipMerges } )` ) ;
963+ Logger . log ( `getLogForFile[Cached(${ key } )]('${ repoPath } ', '${ fileName } ', '${ options . ref } ', ${ options . maxCount } , undefined, ${ options . renames } , ${ options . reverse } )` ) ;
957964 return cachedLog . item ;
958965 }
959966
@@ -962,28 +969,28 @@ export class GitService extends Disposable {
962969 const cachedLog = doc . state . get < CachedLog > ( 'log' ) ;
963970 if ( cachedLog !== undefined ) {
964971 if ( options . ref === undefined ) {
965- Logger . log ( `getLogForFile[Cached(~${ key } )]('${ repoPath } ', '${ fileName } ', '', ${ options . maxCount } , undefined, ${ options . reverse } , ${ options . skipMerges } )` ) ;
972+ Logger . log ( `getLogForFile[Cached(~${ key } )]('${ repoPath } ', '${ fileName } ', '', ${ options . maxCount } , undefined, ${ options . renames } , ${ options . reverse } )` ) ;
966973 return cachedLog . item ;
967974 }
968975
969- Logger . log ( `getLogForFile[? Cache(${ key } )]('${ repoPath } ', '${ fileName } ', '${ options . ref } ', ${ options . maxCount } , undefined, ${ options . reverse } , ${ options . skipMerges } )` ) ;
976+ Logger . log ( `getLogForFile[? Cache(${ key } )]('${ repoPath } ', '${ fileName } ', '${ options . ref } ', ${ options . maxCount } , undefined, ${ options . renames } , ${ options . reverse } )` ) ;
970977 const log = await cachedLog . item ;
971978 if ( log !== undefined && log . commits . has ( options . ref ) ) {
972- Logger . log ( `getLogForFile[Cached(${ key } )]('${ repoPath } ', '${ fileName } ', '${ options . ref } ', ${ options . maxCount } , undefined, ${ options . reverse } , ${ options . skipMerges } )` ) ;
979+ Logger . log ( `getLogForFile[Cached(${ key } )]('${ repoPath } ', '${ fileName } ', '${ options . ref } ', ${ options . maxCount } , undefined, ${ options . renames } , ${ options . reverse } )` ) ;
973980 return cachedLog . item ;
974981 }
975982 }
976983 }
977984 }
978985
979- Logger . log ( `getLogForFile[Not Cached(${ key } )]('${ repoPath } ', '${ fileName } ', ${ options . ref } , ${ options . maxCount } , undefined, ${ options . reverse } , ${ options . skipMerges } )` ) ;
986+ Logger . log ( `getLogForFile[Not Cached(${ key } )]('${ repoPath } ', '${ fileName } ', ${ options . ref } , ${ options . maxCount } , undefined, ${ options . reverse } )` ) ;
980987
981988 if ( doc . state === undefined ) {
982989 doc . state = new GitDocumentState ( doc . key ) ;
983990 }
984991 }
985992 else {
986- Logger . log ( `getLogForFile('${ repoPath } ', '${ fileName } ', ${ options . ref } , ${ options . maxCount } , ${ options . range && `[${ options . range . start . line } , ${ options . range . end . line } ]` } , ${ options . reverse } , ${ options . skipMerges } )` ) ;
993+ Logger . log ( `getLogForFile('${ repoPath } ', '${ fileName } ', ${ options . ref } , ${ options . maxCount } , ${ options . range && `[${ options . range . start . line } , ${ options . range . end . line } ]` } , ${ options . reverse } )` ) ;
987994 }
988995
989996 const promise = this . getLogForFileCore ( repoPath , fileName , options , doc , key ) ;
@@ -999,7 +1006,7 @@ export class GitService extends Disposable {
9991006 return promise ;
10001007 }
10011008
1002- private async getLogForFileCore ( repoPath : string | undefined , fileName : string , options : { maxCount ?: number , range ?: Range , ref ?: string , reverse ?: boolean , skipMerges ?: boolean } , document : TrackedDocument < GitDocumentState > , key : string ) : Promise < GitLog | undefined > {
1009+ private async getLogForFileCore ( repoPath : string | undefined , fileName : string , options : { maxCount ?: number , range ?: Range , ref ?: string , renames ?: boolean , reverse ?: boolean } , document : TrackedDocument < GitDocumentState > , key : string ) : Promise < GitLog | undefined > {
10031010 if ( ! ( await this . isTracked ( fileName , repoPath , { ref : options . ref } ) ) ) {
10041011 Logger . log ( `Skipping log; '${ fileName } ' is not tracked` ) ;
10051012 return GitService . emptyPromise as Promise < GitLog > ;
0 commit comments