FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

make index.addAll use status to speed up · nodegit/nodegit@9417492 · GitHub

Repository navigation

Commit 9417492

Browse files
committed
make index.addAll use status to speed up
1 parent 8b3753f commit 9417492

1 file changed

Lines changed: 16 additions & 2 deletions

File tree

‎lib/index.js‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
var NodeGit = require("../");
22

33
var Index = NodeGit.Index;
4-
4+
var Status = NodeGit.Status;
55
/**
66
* Return an array of the entries in this index.
77
* @return {Array<IndexEntry>} an array of IndexEntrys
@@ -19,7 +19,21 @@ Index.prototype.entries = function() {
1919

2020
var addAll = Index.prototype.addAll;
2121
Index.prototype.addAll = function(pathspec, flags, matchedCallback) {
22-
return addAll.call(this, pathspec || "*", flags, matchedCallback, null);
22+
// This status path code is here to speedup addall, which currently is
23+
// excessively slow due to adding every single unignored file to the index
24+
// even if it has no changes. Remove this when it's fixed in libgit2
25+
// https://github.com/libgit2/libgit2/issues/2687
26+
var paths = [];
27+
var statusCB = function(path) {
28+
paths.push(path);
29+
};
30+
return NodeGit.Status.foreach(repo, statusCB)
31+
.then(function() {
32+
return Promise.resolve(paths);
33+
})
34+
.then(function(paths) {
35+
return addAll.call(this, pathspec || "*", flags, matchedCallback, null);
36+
});
2337
};
2438

2539
var removeAll = Index.prototype.removeAll;

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL