File tree Expand file tree Collapse file tree 1 file changed +19
-7
lines changed Expand file tree Collapse file tree 1 file changed +19
-7
lines changed Original file line number Diff line number Diff line change @@ -972,14 +972,26 @@ export class IsomorphicGit extends GitManager {
972
972
const stagedContent = new TextDecoder ( ) . decode ( stagedBlob ) ;
973
973
974
974
if ( stagedChanges ) {
975
- const headBlob = await readBlob ( {
976
- ...this . getRepo ( ) ,
977
- filepath : filePath ,
978
- oid : await this . resolveRef ( "HEAD" ) ,
979
- } ) ;
980
- const headContent = new TextDecoder ( ) . decode ( headBlob . blob ) ;
975
+ const headContent = await this . resolveRef ( "HEAD" )
976
+ . then ( ( oid ) =>
977
+ readBlob ( {
978
+ ...this . getRepo ( ) ,
979
+ filepath : filePath ,
980
+ oid : oid ,
981
+ } )
982
+ )
983
+ . then ( ( headBlob ) => new TextDecoder ( ) . decode ( headBlob . blob ) )
984
+ . catch ( ( err ) => {
985
+ if ( err instanceof git . Errors . NotFoundError )
986
+ return undefined ;
987
+ throw err ;
988
+ } ) ;
981
989
982
- const diff = createPatch ( filePath , headContent , stagedContent ) ;
990
+ const diff = createPatch (
991
+ filePath ,
992
+ headContent ?? "" ,
993
+ stagedContent
994
+ ) ;
983
995
return diff ;
984
996
} else {
985
997
let workdirContent : string ;
You can’t perform that action at this time.
0 commit comments