@@ -98,11 +98,21 @@ export class GitCommit {
9898 return GitUri . getFormattedPath ( this . fileName , separator ) ;
9999 }
100100
101- with ( changes : { type ?: GitCommitType , fileName ?: string , sha ?: string , originalFileName ?: string , previousFileName ?: string , previousSha ?: string } ) {
102- return new GitCommit ( changes . type || this . type , this . repoPath ,
103- changes . sha || this . sha , changes . fileName || this . fileName ,
104- this . author , this . date , this . message ,
105- changes . originalFileName || this . originalFileName ,
106- changes . previousSha || this . previousSha , changes . previousFileName || this . previousFileName ) ;
101+ with ( changes : { type ?: GitCommitType , sha ?: string , fileName ?: string , originalFileName ?: string | null , previousFileName ?: string | null , previousSha ?: string | null } ) : GitCommit {
102+ return new GitCommit ( changes . type || this . type ,
103+ this . repoPath ,
104+ changes . sha || this . sha ,
105+ changes . fileName || this . fileName ,
106+ this . author ,
107+ this . date ,
108+ this . message ,
109+ this . getChangedValue ( changes . originalFileName , this . originalFileName ) ,
110+ this . getChangedValue ( changes . previousSha , this . previousSha ) ,
111+ this . getChangedValue ( changes . previousFileName , this . previousFileName ) ) ;
112+ }
113+
114+ protected getChangedValue < T > ( change : T | null | undefined , original : T | undefined ) : T | undefined {
115+ if ( change === undefined ) return original ;
116+ return change !== null ? change : undefined ;
107117 }
108118}
0 commit comments