Skip to content

Commit 1b4c474

Browse files
committed
Merge pull request #285 from nodegit/details-for-tree-entry
Add details-for-tree-entry
2 parents 48c74ea + e650616 commit 1b4c474

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

example/details-for-tree-entry.js

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
var nodegit = require('../');
2+
var path = require('path');
3+
4+
/**
5+
* This shows how to get details from a tree entry or a blob
6+
**/
7+
8+
nodegit.Repository.open(path.resolve(__dirname, '../.git'))
9+
.then(function(repo) {
10+
return repo.getTree(
11+
nodegit.Oid.fromString("e1b0c7ea57bfc5e30ec279402a98168a27838ac9"))
12+
.then(function(tree) {
13+
var treeEntry = tree.entryByIndex(0);
14+
15+
// Tree entry doesn't have any data associated with the actual entry
16+
// To get that we need to get the index entry that this points to
17+
return repo.openIndex().then(function(index) {
18+
var indexEntry = index.getByPath(treeEntry.path());
19+
20+
// With the index entry we can now view the details for the tree entry
21+
console.log("Entry path: " + indexEntry.path());
22+
console.log("Entry time in seconds: " + indexEntry.mtime().seconds());
23+
console.log("Entry oid: " + indexEntry.id().toString());
24+
console.log("Entry size: " + indexEntry.fileSize());
25+
});
26+
})
27+
}).done(function() {
28+
console.log("Done!");
29+
});

generate/descriptor.json

+7
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,13 @@
601601
"git_index_free": {
602602
"ignore": true
603603
},
604+
"git_index_get_bypath": {
605+
"args": {
606+
"stage": {
607+
"isOptional": true
608+
}
609+
}
610+
},
604611
"git_index_new": {
605612
"ignore": true
606613
},

0 commit comments

Comments
 (0)