@@ -150,15 +150,15 @@ function getPathHunks(repo, index, filePath, isStaged, additionalDiffOptions) {
150150 } ) ;
151151 } )
152152 . then ( function ( diff ) {
153- if ( ! ( NodeGit . Status . file ( repo , filePath ) &
154- NodeGit . Status . STATUS . WT_MODIFIED ) &&
155- ! ( NodeGit . Status . file ( repo , filePath ) &
156- NodeGit . Status . STATUS . INDEX_MODIFIED ) ) {
157- return Promise . reject
158- ( "Selected staging is only available on modified files." ) ;
159- }
160-
161- return diff . patches ( ) ;
153+ return NodeGit . Status . file ( repo , filePath )
154+ . then ( function ( status ) {
155+ if ( ! ( status & NodeGit . Status . STATUS . WT_MODIFIED ) & &
156+ ! ( status & NodeGit . Status . STATUS . INDEX_MODIFIED ) ) {
157+ return Promise . reject
158+ ( "Selected staging is only available on modified files." ) ;
159+ }
160+ return diff . patches ( ) ;
161+ } ) ;
162162 } )
163163 . then ( function ( patches ) {
164164 var pathPatch = patches . filter ( function ( patch ) {
@@ -1636,17 +1636,42 @@ Repository.prototype.stageFilemode =
16361636 } )
16371637 . then ( function ( diff ) {
16381638 var origLength = filePaths . length ;
1639- filePaths = filePaths . filter ( function ( p ) {
1640- return (
1641- ( NodeGit . Status . file ( repo , p ) & NodeGit . Status . STATUS . WT_MODIFIED ) ||
1642- ( NodeGit . Status . file ( repo , p ) & NodeGit . Status . STATUS . INDEX_MODIFIED )
1643- ) ;
1644- } ) ;
1645- if ( filePaths . length === 0 && origLength > 0 ) {
1646- return Promise . reject
1647- ( "Selected staging is only available on modified files." ) ;
1648- }
1649- return diff . patches ( ) ;
1639+ var fileFilterPromises = fp . map ( function ( p ) {
1640+ return NodeGit . Status . file ( repo , p )
1641+ . then ( function ( status ) {
1642+ return {
1643+ path : p ,
1644+ filter : (
1645+ ( status & NodeGit . Status . STATUS . WT_MODIFIED ) ||
1646+ ( status & NodeGit . Status . STATUS . INDEX_MODIFIED )
1647+ )
1648+ } ;
1649+ } ) ;
1650+ } , filePaths ) ;
1651+
1652+ return Promise . all ( fileFilterPromises )
1653+ . then ( function ( results ) {
1654+ filePaths = fp . flow ( [
1655+ fp . filter ( function ( filterResult ) {
1656+ return filterResult . filter ;
1657+ } ) ,
1658+ fp . map ( function ( filterResult ) {
1659+ return filterResult . path ;
1660+ } )
1661+ ] ) ( results ) ;
1662+
1663+ if ( filePaths . length === 0 && origLength > 0 ) {
1664+ return Promise . reject
1665+ ( "Selected staging is only available on modified files." ) ;
1666+ }
1667+ return diff . patches ( ) ;
1668+ } ) ;
1669+ // filePaths = filePaths.filter(function(p) {
1670+ // return (
1671+ // (NodeGit.Status.file(repo, p) & NodeGit.Status.STATUS.WT_MODIFIED) ||
1672+ // (NodeGit.Status.file(repo, p) & NodeGit.Status.STATUS.INDEX_MODIFIED)
1673+ // );
1674+ // });
16501675 } )
16511676 . then ( function ( patches ) {
16521677 var pathPatches = patches . filter ( function ( patch ) {
0 commit comments