11var NodeGit = require ( "../" ) ;
22
33var Index = NodeGit . Index ;
4-
4+ var Status = NodeGit . Status ;
5+ var Promise = require ( "nodegit-promise" ) ;
56/**
67 * Return an array of the entries in this index.
78 * @return {Array<IndexEntry> } an array of IndexEntrys
@@ -19,7 +20,21 @@ Index.prototype.entries = function() {
1920
2021var addAll = Index . prototype . addAll ;
2122Index . prototype . addAll = function ( pathspec , flags , matchedCallback ) {
22- return addAll . call ( this , pathspec || "*" , flags , matchedCallback , null ) ;
23+ // This status path code is here to speedup addall, which currently is
24+ // excessively slow due to adding every single unignored file to the index
25+ // even if it has no changes. Remove this when it's fixed in libgit2
26+ // https://github.com/libgit2/libgit2/issues/2687
27+ var paths = [ ] ;
28+ var statusCB = function ( path ) {
29+ paths . push ( path ) ;
30+ } ;
31+ return Status . foreach ( this . owner ( ) , statusCB )
32+ . then ( function ( ) {
33+ return Promise . resolve ( paths ) ;
34+ } )
35+ . then ( function ( paths ) {
36+ return addAll . call ( this , pathspec || "*" , flags , matchedCallback , null ) ;
37+ } ) ;
2338} ;
2439
2540var removeAll = Index . prototype . removeAll ;
0 commit comments