ParseRefspec parses a given refspec string
(input string, isFetch bool)
| 16 | |
| 17 | // ParseRefspec parses a given refspec string |
| 18 | func ParseRefspec(input string, isFetch bool) (*Refspec, error) { |
| 19 | var ptr *C.git_refspec |
| 20 | |
| 21 | cinput := C.CString(input) |
| 22 | defer C.free(unsafe.Pointer(cinput)) |
| 23 | |
| 24 | runtime.LockOSThread() |
| 25 | defer runtime.UnlockOSThread() |
| 26 | |
| 27 | ret := C.git_refspec_parse(&ptr, cinput, cbool(isFetch)) |
| 28 | if ret < 0 { |
| 29 | return nil, MakeGitError(ret) |
| 30 | } |
| 31 | |
| 32 | spec := &Refspec{ptr: ptr} |
| 33 | runtime.SetFinalizer(spec, (*Refspec).Free) |
| 34 | return spec, nil |
| 35 | } |
| 36 | |
| 37 | // Free releases a refspec object which has been created by ParseRefspec |
| 38 | func (s *Refspec) Free() { |
searching dependent graphs…