File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -761,9 +761,12 @@ export class Repository {
761761 async log ( options ?: LogOptions ) : Promise < Commit [ ] > {
762762 const maxEntries = options && typeof options . maxEntries === 'number' && options . maxEntries > 0 ? options . maxEntries : 32 ;
763763 const args = [ 'log' , '-' + maxEntries , `--pretty=format:${ COMMIT_FORMAT } %x00%x00` ] ;
764- const gitResult = await this . run ( args ) ;
765- if ( gitResult . exitCode ) {
766- // An empty repo.
764+
765+ let gitResult : IExecutionResult < string > ;
766+ try {
767+ gitResult = await this . run ( args ) ;
768+ } catch ( err ) {
769+ // An empty repo
767770 return [ ] ;
768771 }
769772
@@ -1163,9 +1166,15 @@ export class Repository {
11631166
11641167 let mode : string ;
11651168 let add : string = '' ;
1169+ let treeish : string = '' ;
1170+ const commits = await this . log ( { maxEntries : 1 } ) ;
1171+
1172+ if ( commits . length > 0 ) {
1173+ treeish = 'HEAD' ;
1174+ }
11661175
11671176 try {
1168- const details = await this . getObjectDetails ( 'HEAD' , path ) ;
1177+ const details = await this . getObjectDetails ( treeish , path ) ;
11691178 mode = details . mode ;
11701179 } catch ( err ) {
11711180 if ( err . gitErrorCode !== GitErrorCodes . UnknownPath ) {
You can’t perform that action at this time.
0 commit comments