Skip to content

Commit b4f1245

Browse files
committed
enable access to git_index_new and add test (which is only intermittently succeeding)
1 parent 6f700f0 commit b4f1245

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

generate/input/descriptor.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -982,7 +982,7 @@
982982
}
983983
},
984984
"git_index_new": {
985-
"ignore": true
985+
"isAsync": false
986986
},
987987
"git_index_read": {
988988
"args": {

test/tests/index.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,29 @@ describe("Index", function() {
3333
this.index.clear();
3434
});
3535

36+
it("can create a new index and add entries", function(){
37+
38+
var index = NodeGit.Index.create();
39+
//create file entry
40+
var fileContent = new Buffer("first file content", "binary");
41+
var newFileOid = NodeGit.Blob.createFromBuffer(this.repository,
42+
fileContent,
43+
fileContent.length);
44+
var fileEntry = new NodeGit.IndexEntry();
45+
fileEntry.path = "sub/folder/firstfile.txt";
46+
fileEntry.id = newFileOid;
47+
fileEntry.mode = NodeGit.TreeEntry.FILEMODE.BLOB;
48+
fileEntry.ctime.seconds = new Date().getTime();
49+
fileEntry.mtime.seconds = new Date().getTime();
50+
//add entry to index
51+
index.add(fileEntry);
52+
//check index has entry
53+
assert.equal(1, index.entries().length, "Index should contain entry");
54+
//check for conflicts, which there of course should definitely not be
55+
// considering this is a new index, and we've only added 1 entry
56+
assert.equal(false,index.hasConflicts(), "Index should not have conflicts");
57+
});
58+
3659
it("can get the index of a repo and examine entries", function() {
3760
var entries = this.index.entries();
3861

0 commit comments

Comments
 (0)