populateCheckoutOptions populates the provided C-struct with the contents of the provided CheckoutOptions struct. Returns copts, or nil if opts is nil, in order to help with what to pass.
(copts *C.git_checkout_options, opts *CheckoutOptions, errorTarget *error)
| 140 | // the provided CheckoutOptions struct. Returns copts, or nil if opts is nil, |
| 141 | // in order to help with what to pass. |
| 142 | func populateCheckoutOptions(copts *C.git_checkout_options, opts *CheckoutOptions, errorTarget *error) *C.git_checkout_options { |
| 143 | C.git_checkout_options_init(copts, C.GIT_CHECKOUT_OPTIONS_VERSION) |
| 144 | if opts == nil { |
| 145 | return nil |
| 146 | } |
| 147 | |
| 148 | copts.checkout_strategy = C.uint(opts.Strategy) |
| 149 | copts.disable_filters = cbool(opts.DisableFilters) |
| 150 | copts.dir_mode = C.uint(opts.DirMode.Perm()) |
| 151 | copts.file_mode = C.uint(opts.FileMode.Perm()) |
| 152 | copts.notify_flags = C.uint(opts.NotifyFlags) |
| 153 | if opts.NotifyCallback != nil || opts.ProgressCallback != nil { |
| 154 | C._go_git_populate_checkout_callbacks(copts) |
| 155 | data := &checkoutCallbackData{ |
| 156 | options: opts, |
| 157 | errorTarget: errorTarget, |
| 158 | } |
| 159 | payload := pointerHandles.Track(data) |
| 160 | if opts.NotifyCallback != nil { |
| 161 | copts.notify_payload = payload |
| 162 | } |
| 163 | if opts.ProgressCallback != nil { |
| 164 | copts.progress_payload = payload |
| 165 | } |
| 166 | } |
| 167 | if opts.TargetDirectory != "" { |
| 168 | copts.target_directory = C.CString(opts.TargetDirectory) |
| 169 | } |
| 170 | if len(opts.Paths) > 0 { |
| 171 | copts.paths.strings = makeCStringsFromStrings(opts.Paths) |
| 172 | copts.paths.count = C.size_t(len(opts.Paths)) |
| 173 | } |
| 174 | |
| 175 | if opts.Baseline != nil { |
| 176 | copts.baseline = opts.Baseline.cast_ptr |
| 177 | } |
| 178 | |
| 179 | return copts |
| 180 | } |
| 181 | |
| 182 | func freeCheckoutOptions(copts *C.git_checkout_options) { |
| 183 | if copts == nil { |
no test coverage detected
searching dependent graphs…