@@ -1199,8 +1199,16 @@ export class PullRequestModel extends IssueModel<PullRequest> implements IPullRe
11991199 return ;
12001200 }
12011201
1202+ // Get the commit to find its parent
1203+ const commit = await repository . getCommit ( commitSha ) ;
1204+ if ( ! commit . parents || commit . parents . length === 0 ) {
1205+ vscode . window . showErrorMessage ( vscode . l10n . t ( 'Commit {0} has no parent' , commitSha . substring ( 0 , 7 ) ) ) ;
1206+ return ;
1207+ }
1208+ const parentSha = commit . parents [ 0 ] ;
1209+
12021210 // Get the changes between the commit and its parent
1203- const changes = await repository . diffBetween ( commitSha + '~1' , commitSha ) ;
1211+ const changes = await repository . diffBetween ( parentSha , commitSha ) ;
12041212 if ( ! changes || changes . length === 0 ) {
12051213 vscode . window . showInformationMessage ( vscode . l10n . t ( 'No changes found in commit {0}' , commitSha . substring ( 0 , 7 ) ) ) ;
12061214 return ;
@@ -1218,17 +1226,17 @@ export class PullRequestModel extends IssueModel<PullRequest> implements IPullRe
12181226 args . push ( [ headUri , undefined , headUri ] ) ;
12191227 } else if ( change . status === GitChangeType . DELETE ) {
12201228 // For deleted files, show old version against empty
1221- const baseUri = toReviewUri ( uri , fileName , undefined , commitSha + '~1' , false , { base : true } , repository . rootUri ) ;
1229+ const baseUri = toReviewUri ( uri , fileName , undefined , parentSha , false , { base : true } , repository . rootUri ) ;
12221230 args . push ( [ uri , baseUri , undefined ] ) ;
12231231 } else if ( change . status === GitChangeType . RENAME ) {
12241232 // For renamed files, show old name against new name
12251233 const baseFileName = change . originalUri . fsPath ;
1226- const baseUri = toReviewUri ( uri , baseFileName , undefined , commitSha + '~1' , false , { base : true } , repository . rootUri ) ;
1234+ const baseUri = toReviewUri ( uri , baseFileName , undefined , parentSha , false , { base : true } , repository . rootUri ) ;
12271235 const headUri = toReviewUri ( uri , fileName , undefined , commitSha , false , { base : false } , repository . rootUri ) ;
12281236 args . push ( [ headUri , baseUri , headUri ] ) ;
12291237 } else {
12301238 // For modified files, show before and after
1231- const baseUri = toReviewUri ( uri , fileName , undefined , commitSha + '~1' , false , { base : true } , repository . rootUri ) ;
1239+ const baseUri = toReviewUri ( uri , fileName , undefined , parentSha , false , { base : true } , repository . rootUri ) ;
12321240 const headUri = toReviewUri ( uri , fileName , undefined , commitSha , false , { base : false } , repository . rootUri ) ;
12331241 args . push ( [ headUri , baseUri , headUri ] ) ;
12341242 }
0 commit comments