@@ -1361,20 +1361,22 @@ Repository.prototype.stageLines =
13611361
13621362 var repo = this ;
13631363 var index ;
1364- var diffPromise = isSelectionStaged ?
1365- repo . getHeadCommit ( )
1366- . then ( function getTreeFromCommit ( commit ) {
1367- return commit . getTree ( ) ;
1368- } )
1369- . then ( function getDiffFromTree ( tree ) {
1370- return NodeGit . Diff . treeToIndex ( repo , tree , index ) ;
1371- } )
1372- :
1373- NodeGit . Diff . indexToWorkdir ( repo , index , {
1374- flags :
1375- NodeGit . Diff . OPTION . SHOW_UNTRACKED_CONTENT |
1376- NodeGit . Diff . OPTION . RECURSE_UNTRACKED_DIRS
1377- } ) ;
1364+ var diffPromise = function diffPromise ( ) {
1365+ return isSelectionStaged ?
1366+ repo . getHeadCommit ( )
1367+ . then ( function getTreeFromCommit ( commit ) {
1368+ return commit . getTree ( ) ;
1369+ } )
1370+ . then ( function getDiffFromTree ( tree ) {
1371+ return NodeGit . Diff . treeToIndex ( repo , tree , index ) ;
1372+ } )
1373+ :
1374+ NodeGit . Diff . indexToWorkdir ( repo , index , {
1375+ flags :
1376+ NodeGit . Diff . OPTION . SHOW_UNTRACKED_CONTENT |
1377+ NodeGit . Diff . OPTION . RECURSE_UNTRACKED_DIRS
1378+ } ) ;
1379+ } ;
13781380
13791381 //The following chain checks if there is a patch with no hunks left for the
13801382 //file, and no filemode changes were done on the file. It is then safe to
@@ -1409,18 +1411,13 @@ Repository.prototype.stageLines =
14091411 } ) ;
14101412 } ;
14111413
1412- var indexLock = repo . path ( ) . replace ( ".git/" , "" ) + ".git/index.lock" ;
1413-
1414- return fse . remove ( indexLock )
1415- . then ( function ( ) {
1416- return repo . openIndex ( ) ;
1417- } )
1414+ return repo . openIndex ( )
14181415 . then ( function ( indexResult ) {
14191416 index = indexResult ;
14201417 return index . read ( 1 ) ;
14211418 } )
14221419 . then ( function ( ) {
1423- return diffPromise ;
1420+ return diffPromise ( ) ;
14241421 } )
14251422 . then ( function ( diff ) {
14261423 if ( ! ( NodeGit . Status . file ( repo , filePath ) &
0 commit comments