diff options
| author | Axel Wagner <[email protected]> | 2013-05-14 21:34:07 +0200 |
|---|---|---|
| committer | Axel Wagner <[email protected]> | 2013-05-14 21:35:58 +0200 |
| commit | e1238b5994f160a72d8723f7e680a308391a99d9 (patch) | |
| tree | 4902a15085738495556c487065724304e7c1e4eb | |
| parent | c9adbf05d77d17e9b6de0b9c674e2c1e61744bcc (diff) | |
Implement git_repository_discover
| -rw-r--r-- | git.go | 27 |
1 files changed, 27 insertions, 0 deletions
@@ -9,6 +9,7 @@ import "C" import ( "bytes" "unsafe" + "strings" ) const ( @@ -122,3 +123,29 @@ func ucbool(b bool) C.uint { } return C.uint(0) } + +func Discover(start string, across_fs bool, ceiling_dirs []string) (string, error) { + ceildirs := C.CString(strings.Join(ceiling_dirs, string(C.GIT_PATH_LIST_SEPARATOR))) + defer C.free(unsafe.Pointer(ceildirs)) + + 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 acrfs C.int + if across_fs { + acrfs = 1 + } else { + acrfs = 0 + } + + r := C.git_repository_discover(retpath, C.GIT_PATH_MAX, cstart, acrfs, ceildirs) + + if r == 0 { + return C.GoString(retpath), nil + } + + return "", LastError() +} |
