summaryrefslogtreecommitdiff
path: root/git.go
diff options
context:
space:
mode:
authorCarlos Martín Nieto <[email protected]>2014-02-23 15:31:22 +0100
committerCarlos Martín Nieto <[email protected]>2014-02-23 15:31:22 +0100
commit1b09b03c0eecc4f5bad58e5647460cb8680a2188 (patch)
tree32dac887b2d360d9a313e4956263cad3ca8761b2 /git.go
parent66e1c476199ebcd3e304659992233132c5a52c6c (diff)
parentf66502aaf44862a8671285e80327d808afee155f (diff)
Merge commit 'refs/pull/53/head' of github.com:libgit2/git2go
On top: fix git_buf handling and rename signature This fixes #57, #54. Conflicts: git.go reference.go repository.go submodule.go
Diffstat (limited to 'git.go')
-rw-r--r--git.go23
1 files changed, 11 insertions, 12 deletions
diff --git a/git.go b/git.go
index 28196c8..72ea33e 100644
--- a/git.go
+++ b/git.go
@@ -93,7 +93,7 @@ func (oid *Oid) Equal(oid2 *Oid) bool {
}
func (oid *Oid) IsZero() bool {
- for _, a := range(oid.bytes) {
+ for _, a := range oid.bytes {
if a != '0' {
return false
}
@@ -131,10 +131,10 @@ func ShortenOids(ids []*Oid, minlen int) (int, error) {
type GitError struct {
Message string
- Code int
+ Code int
}
-func (e GitError) Error() string{
+func (e GitError) Error() string {
return e.Message
}
@@ -147,14 +147,14 @@ func LastError() error {
}
func cbool(b bool) C.int {
- if (b) {
+ if b {
return C.int(1)
}
return C.int(0)
}
func ucbool(b bool) C.uint {
- if (b) {
+ if b {
return C.uint(1)
}
return C.uint(0)
@@ -167,17 +167,16 @@ func Discover(start string, across_fs bool, ceiling_dirs []string) (string, erro
cstart := C.CString(start)
defer C.free(unsafe.Pointer(cstart))
- retpath := (*C.char)(C.malloc(C.GIT_PATH_MAX))
- defer C.free(unsafe.Pointer(retpath))
+ var buf C.git_buf
+ defer C.git_buf_free(&buf)
runtime.LockOSThread()
defer runtime.UnlockOSThread()
- r := C.git_repository_discover(retpath, C.GIT_PATH_MAX, cstart, cbool(across_fs), ceildirs)
-
- if r == 0 {
- return C.GoString(retpath), nil
+ ret := C.git_repository_discover(&buf, cstart, cbool(across_fs), ceildirs)
+ if ret < 0 {
+ return "", LastError()
}
- return "", LastError()
+ return C.GoString(buf.ptr), nil
}