summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlos Martín Nieto <[email protected]>2015-09-30 08:53:05 +0200
committerCarlos Martín Nieto <[email protected]>2015-09-30 08:53:05 +0200
commit698ed4a42d86ae88682379c4ad6f209735d0bf33 (patch)
tree9df72f1b6a88cb4274e28b9c4752bdb4d7085f8a
parent0522886781055d59b780e00fddf3c8f7c9e118dc (diff)
parentb8283e72771866cae56c9036ace2ff80f125ff50 (diff)
Merge pull request #260 from clearr/index-entrybypath
Add EntryByPath method to Index
-rw-r--r--index.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/index.go b/index.go
index f4c0c1e..06495b9 100644
--- a/index.go
+++ b/index.go
@@ -331,6 +331,17 @@ func (v *Index) EntryByIndex(index uint) (*IndexEntry, error) {
return newIndexEntryFromC(centry), nil
}
+func (v *Index) EntryByPath(path string, stage int) (*IndexEntry, error) {
+ runtime.LockOSThread()
+ defer runtime.UnlockOSThread()
+
+ centry := C.git_index_get_bypath(v.ptr, C.CString(path), C.int(stage))
+ if centry == nil {
+ return nil, MakeGitError(C.GIT_ENOTFOUND)
+ }
+ return newIndexEntryFromC(centry), nil
+}
+
func (v *Index) HasConflicts() bool {
return C.git_index_has_conflicts(v.ptr) != 0
}