InitRebase initializes a rebase operation to rebase the changes in branch relative to upstream onto another branch.
(branch *AnnotatedCommit, upstream *AnnotatedCommit, onto *AnnotatedCommit, opts *RebaseOptions)
| 287 | |
| 288 | // InitRebase initializes a rebase operation to rebase the changes in branch relative to upstream onto another branch. |
| 289 | func (r *Repository) InitRebase(branch *AnnotatedCommit, upstream *AnnotatedCommit, onto *AnnotatedCommit, opts *RebaseOptions) (*Rebase, error) { |
| 290 | runtime.LockOSThread() |
| 291 | defer runtime.UnlockOSThread() |
| 292 | |
| 293 | if branch == nil { |
| 294 | branch = &AnnotatedCommit{ptr: nil} |
| 295 | } |
| 296 | |
| 297 | if upstream == nil { |
| 298 | upstream = &AnnotatedCommit{ptr: nil} |
| 299 | } |
| 300 | |
| 301 | if onto == nil { |
| 302 | onto = &AnnotatedCommit{ptr: nil} |
| 303 | } |
| 304 | |
| 305 | var ptr *C.git_rebase |
| 306 | var err error |
| 307 | cOpts := populateRebaseOptions(&C.git_rebase_options{}, opts, r, &err) |
| 308 | ret := C.git_rebase_init(&ptr, r.ptr, branch.ptr, upstream.ptr, onto.ptr, cOpts) |
| 309 | runtime.KeepAlive(branch) |
| 310 | runtime.KeepAlive(upstream) |
| 311 | runtime.KeepAlive(onto) |
| 312 | if ret == C.int(ErrorCodeUser) && err != nil { |
| 313 | freeRebaseOptions(cOpts) |
| 314 | return nil, err |
| 315 | } |
| 316 | if ret < 0 { |
| 317 | freeRebaseOptions(cOpts) |
| 318 | return nil, MakeGitError(ret) |
| 319 | } |
| 320 | |
| 321 | return newRebaseFromC(ptr, r, cOpts), nil |
| 322 | } |
| 323 | |
| 324 | // OpenRebase opens an existing rebase that was previously started by either an invocation of InitRebase or by another client. |
| 325 | func (r *Repository) OpenRebase(opts *RebaseOptions) (*Rebase, error) { |