diff options
| author | Geoffrey Ragot <[email protected]> | 2015-03-14 15:27:47 +0100 |
|---|---|---|
| committer | Geoffrey Ragot <[email protected]> | 2015-03-15 10:14:29 +0100 |
| commit | c4b8861b34ead7b06986ea5711c2d9528628215f (patch) | |
| tree | 2692c6b86b39750c6062d1501189beb4bffa1cf5 /checkout.go | |
| parent | 755721e68453c5d6de0681789dbe3307744fc9c4 (diff) | |
Add possibiliy of checkout on specific path
Diffstat (limited to 'checkout.go')
| -rw-r--r-- | checkout.go | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/checkout.go b/checkout.go index 06d010c..c507172 100644 --- a/checkout.go +++ b/checkout.go @@ -38,6 +38,7 @@ 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 } func (opts *CheckoutOpts) toC() *C.git_checkout_options { @@ -65,6 +66,11 @@ func populateCheckoutOpts(ptr *C.git_checkout_options, opts *CheckoutOpts) *C.gi if opts.TargetDirectory != "" { ptr.target_directory = C.CString(opts.TargetDirectory) } + if len(opts.Paths) > 0 { + ptr.paths.strings = makeCStringsFromStrings(opts.Paths) + ptr.paths.count = C.size_t(len(opts.Paths)) + } + return ptr } @@ -73,6 +79,9 @@ func freeCheckoutOpts(ptr *C.git_checkout_options) { return } C.free(unsafe.Pointer(ptr.target_directory)) + if ptr.paths.count > 0 { + freeStrarray(&ptr.paths) + } } // Updates files in the index and the working tree to match the content of @@ -128,4 +137,4 @@ func (v *Repository) CheckoutTree(tree *Tree, opts *CheckoutOpts) error { } return nil -} +}
\ No newline at end of file |
