diff options
| author | Vicent Martà <[email protected]> | 2013-05-16 17:41:34 -0700 |
|---|---|---|
| committer | Vicent Martà <[email protected]> | 2013-05-16 17:41:34 -0700 |
| commit | b1c3de066f363a9910e3c6bc3dbddbc68386a1c5 (patch) | |
| tree | a6e5ebe6d9266cb5272fda6466c876eaf97f23e6 | |
| parent | a1743f75b2132546d41f0eea486a4961dcf8b435 (diff) | |
| parent | e1238b5994f160a72d8723f7e680a308391a99d9 (diff) | |
Merge pull request #19 from Merovius/discover
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() +} |
