11'use strict' ;
22import { Strings } from '../system' ;
3+ import { SpawnOptions } from 'child_process' ;
34import { findGitPath , IGit } from './gitLocator' ;
45import { Logger } from '../logger' ;
56import { spawnPromise } from 'spawn-rx' ;
@@ -42,6 +43,7 @@ const GitWarnings = [
4243
4344interface GitCommandOptions {
4445 cwd : string ;
46+ env ?: any ;
4547 encoding ?: string ;
4648 overrideErrorHandling ?: boolean ;
4749}
@@ -63,7 +65,12 @@ async function gitCommandCore(options: GitCommandOptions, ...args: any[]): Promi
6365 args . splice ( 0 , 0 , '-c' , 'core.quotepath=false' , '-c' , 'color.ui=false' ) ;
6466
6567 const opts = { encoding : 'utf8' , ...options } ;
66- const s = await spawnPromise ( git . path , args , { cwd : options . cwd , encoding : ( opts . encoding === 'utf8' ) ? 'utf8' : 'binary' } ) ;
68+ const s = await spawnPromise ( git . path , args , {
69+ cwd : options . cwd ,
70+ env : options . env ,
71+ encoding : ( opts . encoding === 'utf8' ) ? 'utf8' : 'binary'
72+ } as SpawnOptions ) ;
73+
6774 Logger . log ( 'git' , ...args , ` cwd='${ options . cwd } '` ) ;
6875 if ( opts . encoding === 'utf8' || opts . encoding === 'binary' ) return s ;
6976
@@ -431,13 +438,13 @@ export class Git {
431438
432439 static status ( repoPath : string , porcelainVersion : number = 1 ) : Promise < string > {
433440 const porcelain = porcelainVersion >= 2 ? `--porcelain=v${ porcelainVersion } ` : '--porcelain' ;
434- return gitCommand ( { cwd : repoPath } , 'status' , porcelain , '--branch' , '-u' ) ;
441+ return gitCommand ( { cwd : repoPath , env : { GIT_OPTIONAL_LOCKS : '0' } } , 'status' , porcelain , '--branch' , '-u' ) ;
435442 }
436443
437444 static status_file ( repoPath : string , fileName : string , porcelainVersion : number = 1 ) : Promise < string > {
438445 const [ file , root ] = Git . splitPath ( fileName , repoPath ) ;
439446
440447 const porcelain = porcelainVersion >= 2 ? `--porcelain=v${ porcelainVersion } ` : '--porcelain' ;
441- return gitCommand ( { cwd : root } , 'status' , porcelain , file ) ;
448+ return gitCommand ( { cwd : root , env : { GIT_OPTIONAL_LOCKS : '0' } } , 'status' , porcelain , file ) ;
442449 }
443450}
0 commit comments