diff --git a/checkout.go b/checkout.go index e0c067e..a2e312b 100644 --- a/checkout.go +++ b/checkout.go @@ -44,7 +44,8 @@ type CheckoutOpts struct { FileMode os.FileMode // Default is 0644 or 0755 as dictated by blob FileOpenFlags int // Default is O_CREAT | O_TRUNC | O_WRONLY TargetDirectory string // Alternative checkout path to workdir - Paths []string + Paths []string + Baseline *Tree } func checkoutOptionsFromC(c *C.git_checkout_options) CheckoutOpts { @@ -90,6 +91,10 @@ func populateCheckoutOpts(ptr *C.git_checkout_options, opts *CheckoutOpts) *C.gi ptr.paths.count = C.size_t(len(opts.Paths)) } + if opts.Baseline != nil { + ptr.baseline = opts.Baseline.cast_ptr + } + return ptr } @@ -156,4 +161,4 @@ func (v *Repository) CheckoutTree(tree *Tree, opts *CheckoutOpts) error { } return nil -} \ No newline at end of file +} diff --git a/status.go b/status.go index 068a474..3f5a06d 100644 --- a/status.go +++ b/status.go @@ -126,24 +126,34 @@ type StatusOptions struct { Pathspec []string } +func (opts *StatusOptions) toC() *C.git_status_options { + if opts == nil { + return nil + } + + cpathspec := C.git_strarray{} + if opts.Pathspec != nil { + cpathspec.count = C.size_t(len(opts.Pathspec)) + cpathspec.strings = makeCStringsFromStrings(opts.Pathspec) + defer freeStrarray(&cpathspec) + } + + copts := &C.git_status_options{ + version: C.GIT_STATUS_OPTIONS_VERSION, + show: C.git_status_show_t(opts.Show), + flags: C.uint(opts.Flags), + pathspec: cpathspec, + } + + return copts +} + func (v *Repository) StatusList(opts *StatusOptions) (*StatusList, error) { var ptr *C.git_status_list var copts *C.git_status_options if opts != nil { - cpathspec := C.git_strarray{} - if opts.Pathspec != nil { - cpathspec.count = C.size_t(len(opts.Pathspec)) - cpathspec.strings = makeCStringsFromStrings(opts.Pathspec) - defer freeStrarray(&cpathspec) - } - - copts = &C.git_status_options{ - version: C.GIT_STATUS_OPTIONS_VERSION, - show: C.git_status_show_t(opts.Show), - flags: C.uint(opts.Flags), - pathspec: cpathspec, - } + copts = opts.toC() } else { copts = &C.git_status_options{} ret := C.git_status_init_options(copts, C.GIT_STATUS_OPTIONS_VERSION)