@@ -205,6 +205,14 @@ function defaultExceptionHandler(ex: Error, options: GitCommandOptions, ...args:
205205 }
206206 }
207207
208+ const match = GitErrors . badRevision . exec ( msg ) ;
209+ if ( match != null && match ) {
210+ const [ , ref ] = match ;
211+
212+ // Since looking up a ref with ^3 (e.g. looking for untracked files in a stash) can error on some versions of git just ignore it
213+ if ( ref != null && ref . endsWith ( '^3' ) ) return '' ;
214+ }
215+
208216 Logger . error ( ex , 'git' , ...args , ` cwd='${ options . cwd } '\n\n ` ) ;
209217 throw ex ;
210218}
@@ -519,7 +527,7 @@ export class Git {
519527 const [ , ref ] = match ;
520528
521529 // If the bad ref is trying to find a parent ref, assume we hit to the last commit, so try again using the root sha
522- if ( ref === ref1 && ref . endsWith ( '^' ) ) {
530+ if ( ref === ref1 && ref != null && ref . endsWith ( '^' ) ) {
523531 return Git . diff ( repoPath , fileName , rootSha , ref2 , options ) ;
524532 }
525533 }
@@ -735,10 +743,10 @@ export class Git {
735743 static async revparse_currentBranch ( repoPath : string ) : Promise < [ string , string | undefined ] | undefined > {
736744 const params = [ 'rev-parse' , '--abbrev-ref' , '--symbolic-full-name' , '@' , '@{u}' ] ;
737745
738- const opts = {
746+ const opts : GitCommandOptions = {
739747 cwd : repoPath ,
740748 errors : GitErrorHandling . Throw
741- } as GitCommandOptions ;
749+ } ;
742750
743751 try {
744752 const data = await git < string > ( opts , ...params ) ;
@@ -789,7 +797,9 @@ export class Git {
789797 repoPath : string | undefined ,
790798 fileName : string ,
791799 ref : string ,
792- options : { encoding ?: string } = { }
800+ options : {
801+ encoding ?: 'binary' | 'ascii' | 'utf8' | 'utf16le' | 'ucs2' | 'base64' | 'latin1' | 'hex' | 'buffer' ;
802+ } = { }
793803 ) : Promise < TOut | undefined > {
794804 const [ file , root ] = Git . splitPath ( fileName , repoPath ) ;
795805
@@ -798,11 +808,11 @@ export class Git {
798808 }
799809 if ( Git . isUncommitted ( ref ) ) throw new Error ( `ref=${ ref } is uncommitted` ) ;
800810
801- const opts = {
811+ const opts : GitCommandOptions = {
802812 cwd : root ,
803813 encoding : options . encoding || 'utf8' ,
804814 errors : GitErrorHandling . Throw
805- } as GitCommandOptions ;
815+ } ;
806816 const args = ref . endsWith ( ':' ) ? `${ ref } ./${ file } ` : `${ ref } :./${ file } ` ;
807817
808818 try {
0 commit comments