MCPcopy Create free account
hub / github.com/libgit2/git2go / performRebaseOnto

Function performRebaseOnto

rebase_test.go:359–416  ·  view source on GitHub ↗
(repo *Repository, branch string, rebaseOpts *RebaseOptions)

Source from the content-addressed store, hash-verified

357}
358
359func performRebaseOnto(repo *Repository, branch string, rebaseOpts *RebaseOptions) (*Rebase, error) {
360 master, err := repo.LookupBranch(branch, BranchLocal)
361 if err != nil {
362 return nil, err
363 }
364 defer master.Free()
365
366 onto, err := repo.AnnotatedCommitFromRef(master.Reference)
367 if err != nil {
368 return nil, err
369 }
370 defer onto.Free()
371
372 // Init rebase
373 rebase, err := repo.InitRebase(nil, nil, onto, rebaseOpts)
374 if err != nil {
375 return nil, err
376 }
377
378 // Check no operation has been started yet
379 rebaseOperationIndex, err := rebase.CurrentOperationIndex()
380 if rebaseOperationIndex != RebaseNoOperation && err != ErrRebaseNoOperation {
381 return nil, errors.New("No operation should have been started yet")
382 }
383
384 // Iterate in rebase operations regarding operation count
385 opCount := int(rebase.OperationCount())
386 for op := 0; op < opCount; op++ {
387 operation, err := rebase.Next()
388 if err != nil {
389 return nil, err
390 }
391
392 // Check operation index is correct
393 rebaseOperationIndex, err = rebase.CurrentOperationIndex()
394 if int(rebaseOperationIndex) != op {
395 return nil, errors.New("Bad operation index")
396 }
397 if !operationsAreEqual(rebase.OperationAt(uint(op)), operation) {
398 return nil, errors.New("Rebase operations should be equal")
399 }
400
401 // Get current rebase operation created commit
402 commit, err := repo.LookupCommit(operation.Id)
403 if err != nil {
404 return nil, err
405 }
406 defer commit.Free()
407
408 // Apply commit
409 err = rebase.Commit(operation.Id, signature(), signature(), commit.Message())
410 if err != nil {
411 return nil, err
412 }
413 }
414
415 return rebase, nil
416}

Callers 3

TestRebaseAbortFunction · 0.85
TestRebaseNoConflictsFunction · 0.85
TestRebaseGpgSignedFunction · 0.85

Calls 13

operationsAreEqualFunction · 0.85
signatureFunction · 0.85
LookupBranchMethod · 0.80
InitRebaseMethod · 0.80
CurrentOperationIndexMethod · 0.80
OperationCountMethod · 0.80
OperationAtMethod · 0.80
LookupCommitMethod · 0.80
FreeMethod · 0.65
NextMethod · 0.45
CommitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…