summaryrefslogtreecommitdiff
path: root/repository.go
diff options
context:
space:
mode:
authorVladimir Buzuev <[email protected]>2021-04-03 16:52:34 -0700
committerGitHub <[email protected]>2021-04-03 16:52:34 -0700
commita4d202ed7b025331ee4a63ebc38f62519cee4750 (patch)
tree33e07d1de842796e2dedf47dd5380b882a88e167 /repository.go
parentaeb22bcf7dd6b3b8f75363a20790b84ea4d5de9f (diff)
Git repository item path (#757)
add wrapper for `git_repository_item_path`
Diffstat (limited to 'repository.go')
-rw-r--r--repository.go36
1 files changed, 35 insertions, 1 deletions
diff --git a/repository.go b/repository.go
index a6eb7f1..cb82fc3 100644
--- a/repository.go
+++ b/repository.go
@@ -739,5 +739,39 @@ func (r *Repository) RemoveMessage() error {
if cErr < 0 {
return MakeGitError(cErr)
}
- return nil
+ return nil
+}
+
+type RepositoryItem int
+
+const (
+ RepositoryItemGitDir RepositoryItem = C.GIT_REPOSITORY_ITEM_GITDIR
+ RepositoryItemWorkDir RepositoryItem = C.GIT_REPOSITORY_ITEM_WORKDIR
+ RepositoryItemCommonDir RepositoryItem = C.GIT_REPOSITORY_ITEM_COMMONDIR
+ RepositoryItemIndex RepositoryItem = C.GIT_REPOSITORY_ITEM_INDEX
+ RepositoryItemObjects RepositoryItem = C.GIT_REPOSITORY_ITEM_OBJECTS
+ RepositoryItemRefs RepositoryItem = C.GIT_REPOSITORY_ITEM_REFS
+ RepositoryItemPackedRefs RepositoryItem = C.GIT_REPOSITORY_ITEM_PACKED_REFS
+ RepositoryItemRemotes RepositoryItem = C.GIT_REPOSITORY_ITEM_REMOTES
+ RepositoryItemConfig RepositoryItem = C.GIT_REPOSITORY_ITEM_CONFIG
+ RepositoryItemInfo RepositoryItem = C.GIT_REPOSITORY_ITEM_INFO
+ RepositoryItemHooks RepositoryItem = C.GIT_REPOSITORY_ITEM_HOOKS
+ RepositoryItemLogs RepositoryItem = C.GIT_REPOSITORY_ITEM_LOGS
+ RepositoryItemModules RepositoryItem = C.GIT_REPOSITORY_ITEM_MODULES
+ RepositoryItemWorkTrees RepositoryItem = C.GIT_REPOSITORY_ITEM_WORKTREES
+)
+
+func (r *Repository) ItemPath(item RepositoryItem) (string, error) {
+ var c_buf C.git_buf
+ defer C.git_buf_dispose(&c_buf)
+
+ runtime.LockOSThread()
+ defer runtime.UnlockOSThread()
+
+ ret := C.git_repository_item_path(&c_buf, r.ptr, C.git_repository_item_t(item))
+ runtime.KeepAlive(r)
+ if ret < 0 {
+ return "", MakeGitError(ret)
+ }
+ return C.GoString(c_buf.ptr), nil
}