@@ -549,9 +549,13 @@ Repository.prototype.createCommitOnHead = function(
549
549
. then ( function ( ) {
550
550
return index . addByPath ( filePath ) ;
551
551
} ) ;
552
- } , Promise . resolve ( ) ) ;
553
- index . write ( ) ;
554
- return index . writeTree ( ) ;
552
+ } , Promise . resolve ( ) )
553
+ . then ( function ( ) {
554
+ return index . write ( ) ;
555
+ } )
556
+ . then ( function ( ) {
557
+ return index . writeTree ( ) ;
558
+ } ) ;
555
559
} )
556
560
. then ( function ( treeOid ) {
557
561
return repo . getHeadCommit ( )
@@ -854,7 +858,6 @@ Repository.prototype.mergeBranches =
854
858
}
855
859
856
860
// No conflicts so just go ahead with the merge
857
- index . write ( ) ;
858
861
return index . writeTreeTo ( repo ) ;
859
862
} )
860
863
. then ( function ( oid ) {
@@ -1292,15 +1295,20 @@ Repository.prototype.stageFilemode = function(filePath, stageNew) {
1292
1295
return Promise . reject ( "No differences found for this file." ) ;
1293
1296
}
1294
1297
1295
- pathPatches . forEach ( function ( pathPatch ) {
1296
- var entry = index . getByPath ( pathPatch . newFile ( ) . path ( ) , 0 ) ;
1297
-
1298
- entry . mode = stageNew ?
1299
- pathPatch . newFile ( ) . mode ( ) : pathPatch . oldFile ( ) . mode ( ) ;
1298
+ return pathPatches
1299
+ . reduce ( function ( lastIndexAddPromise , pathPatch ) {
1300
+ var entry = index . getByPath ( pathPatch . newFile ( ) . path ( ) , 0 ) ;
1300
1301
1301
- index . add ( entry ) ;
1302
- } ) ;
1302
+ entry . mode = stageNew ?
1303
+ pathPatch . newFile ( ) . mode ( ) : pathPatch . oldFile ( ) . mode ( ) ;
1303
1304
1305
+ return lastIndexAddPromise
1306
+ . then ( function ( ) {
1307
+ return index . add ( entry ) ;
1308
+ } ) ;
1309
+ } , Promise . resolve ( ) ) ;
1310
+ } )
1311
+ . then ( function ( ) {
1304
1312
return index . write ( ) ;
1305
1313
} ) ;
1306
1314
} ;
@@ -1461,8 +1469,10 @@ Repository.prototype.stageLines =
1461
1469
! pathPatch [ 0 ] . isTypeChange ( ) ;
1462
1470
}
1463
1471
if ( emptyPatch ) {
1464
- index . addByPath ( filePath ) ;
1465
- return index . write ( ) ;
1472
+ return index . addByPath ( filePath )
1473
+ . then ( function ( ) {
1474
+ return index . write ( ) ;
1475
+ } ) ;
1466
1476
} else {
1467
1477
return result ;
1468
1478
}
@@ -1514,7 +1524,9 @@ Repository.prototype.stageLines =
1514
1524
entry . path = filePath ;
1515
1525
entry . fileSize = newBlob . content ( ) . length ;
1516
1526
1517
- index . add ( entry ) ;
1527
+ return index . add ( entry ) ;
1528
+ } )
1529
+ . then ( function ( ) {
1518
1530
return index . write ( ) ;
1519
1531
} )
1520
1532
. then ( function ( result ) {
0 commit comments