@@ -35,7 +35,7 @@ export class GitCommit implements GitRevisionReference {
3535 commit . message != null &&
3636 commit . files != null &&
3737 commit . parents . length !== 0 &&
38- ( ! commit . stashName || commit . _stashUntrackedFilesLoaded )
38+ ( commit . refType !== 'stash' || commit . _stashUntrackedFilesLoaded )
3939 ) ;
4040 }
4141
@@ -189,36 +189,42 @@ export class GitCommit implements GitRevisionReference {
189189 if ( this . isUncommitted || GitCommit . hasFullDetails ( this ) ) return ;
190190
191191 const [ commitResult , untrackedResult ] = await Promise . allSettled ( [
192- this . container . git . getCommit ( this . repoPath , this . sha ) ,
192+ this . refType !== 'stash' ? this . container . git . getCommit ( this . repoPath , this . sha ) : undefined ,
193193 // Check for any untracked files -- since git doesn't return them via `git stash list` :(
194194 // See https://stackoverflow.com/questions/12681529/
195- this . stashName ? this . container . git . getCommit ( this . repoPath , `${ this . stashName } ^3` ) : undefined ,
195+ this . refType === 'stash' && ! this . _stashUntrackedFilesLoaded
196+ ? this . container . git . getCommit ( this . repoPath , `${ this . stashName } ^3` )
197+ : undefined ,
196198 this . getPreviousSha ( ) ,
197199 ] ) ;
198- if ( commitResult . status !== 'fulfilled' || commitResult . value == null ) return ;
199-
200- let commit = commitResult . value ;
201- this . parents . push ( ...( commit . parents ?? [ ] ) ) ;
202- this . _summary = commit . summary ;
203- this . _message = commit . message ;
204- this . _files = commit . files as GitFileChange [ ] ;
205-
206- if ( this . _file != null ) {
207- const file = this . _files . find ( f => f . path === this . _file ! . path ) ;
208- if ( file != null ) {
209- this . _file = new GitFileChange (
210- file . repoPath ,
211- file . path ,
212- file . status ,
213- file . originalPath ?? this . _file . originalPath ,
214- file . previousSha ?? this . _file . previousSha ,
215- file . stats ?? this . _file . stats ,
216- ) ;
200+
201+ let commit ;
202+
203+ if ( commitResult . status === 'fulfilled' && commitResult . value != null ) {
204+ commit = commitResult . value ;
205+ this . parents . push ( ...( commit . parents ?? [ ] ) ) ;
206+ this . _summary = commit . summary ;
207+ this . _message = commit . message ;
208+ this . _files = commit . files as GitFileChange [ ] ;
209+
210+ if ( this . _file != null ) {
211+ const file = this . _files . find ( f => f . path === this . _file ! . path ) ;
212+ if ( file != null ) {
213+ this . _file = new GitFileChange (
214+ file . repoPath ,
215+ file . path ,
216+ file . status ,
217+ file . originalPath ?? this . _file . originalPath ,
218+ file . previousSha ?? this . _file . previousSha ,
219+ file . stats ?? this . _file . stats ,
220+ ) ;
221+ }
217222 }
218223 }
219224
220225 if ( untrackedResult . status === 'fulfilled' && untrackedResult . value != null ) {
221226 this . _stashUntrackedFilesLoaded = true ;
227+
222228 commit = untrackedResult . value ;
223229 if ( commit ?. files != null && commit . files . length !== 0 ) {
224230 // Since these files are untracked -- make them look that way
@@ -284,13 +290,13 @@ export class GitCommit implements GitRevisionReference {
284290 async findFile ( path : string ) : Promise < GitFileChange | undefined > ;
285291 async findFile ( uri : Uri ) : Promise < GitFileChange | undefined > ;
286292 async findFile ( pathOrUri : string | Uri ) : Promise < GitFileChange | undefined > {
287- if ( this . _files == null ) {
293+ if ( ! GitCommit . hasFullDetails ( this ) ) {
288294 await this . ensureFullDetails ( ) ;
289295 if ( this . _files == null ) return undefined ;
290296 }
291297
292298 const relativePath = this . container . git . getRelativePath ( pathOrUri , this . repoPath ) ;
293- return this . _files . find ( f => f . path === relativePath ) ;
299+ return this . _files ? .find ( f => f . path === relativePath ) ;
294300 }
295301
296302 formatDate ( format ?: string | null ) {
@@ -406,13 +412,13 @@ export class GitCommit implements GitRevisionReference {
406412 }
407413
408414 async getCommitsForFiles ( ) : Promise < GitCommit [ ] > {
409- if ( this . _files == null ) {
415+ if ( ! GitCommit . hasFullDetails ( this ) ) {
410416 await this . ensureFullDetails ( ) ;
411417 if ( this . _files == null ) return [ ] ;
412418 }
413419
414- const commits = this . _files . map ( f => this . with ( { files : { file : f } } ) ) ;
415- return commits ;
420+ const commits = this . _files ? .map ( f => this . with ( { files : { file : f } } ) ) ;
421+ return commits ?? [ ] ;
416422 }
417423
418424 @memoize ( )
0 commit comments