summaryrefslogtreecommitdiff
path: root/rebase.go
diff options
context:
space:
mode:
authorCarlos Martín Nieto <[email protected]>2017-07-08 16:51:22 +0200
committerGitHub <[email protected]>2017-07-08 16:51:22 +0200
commit08db2e2c167404c5ed9be0fc1c995e41bad479bb (patch)
tree4a9c1357f3682d4134318e73ef85aa172cbfbd48 /rebase.go
parent29c0b730076fe402c22ea3e3a11a7ed541663637 (diff)
parent55a1096141519a1f380d0702671cfe9bf90ec435 (diff)
Merge pull request #393 from libgit2/cmn/keepalive-all-the-things
KeepAlive all the things
Diffstat (limited to 'rebase.go')
-rw-r--r--rebase.go16
1 files changed, 14 insertions, 2 deletions
diff --git a/rebase.go b/rebase.go
index 8553e25..390b924 100644
--- a/rebase.go
+++ b/rebase.go
@@ -100,6 +100,7 @@ func mapEmptyStringToNull(ref string) *C.char {
// Rebase is the struct representing a Rebase object.
type Rebase struct {
ptr *C.git_rebase
+ r *Repository
}
// InitRebase initializes a rebase operation to rebase the changes in branch relative to upstream onto another branch.
@@ -121,6 +122,9 @@ func (r *Repository) InitRebase(branch *AnnotatedCommit, upstream *AnnotatedComm
var ptr *C.git_rebase
err := C.git_rebase_init(&ptr, r.ptr, branch.ptr, upstream.ptr, onto.ptr, opts.toC())
+ runtime.KeepAlive(branch)
+ runtime.KeepAlive(upstream)
+ runtime.KeepAlive(onto)
if err < 0 {
return nil, MakeGitError(err)
}
@@ -135,6 +139,7 @@ func (r *Repository) OpenRebase(opts *RebaseOptions) (*Rebase, error) {
var ptr *C.git_rebase
err := C.git_rebase_open(&ptr, r.ptr, opts.toC())
+ runtime.KeepAlive(r)
if err < 0 {
return nil, MakeGitError(err)
}
@@ -145,7 +150,7 @@ func (r *Repository) OpenRebase(opts *RebaseOptions) (*Rebase, error) {
// OperationAt gets the rebase operation specified by the given index.
func (rebase *Rebase) OperationAt(index uint) *RebaseOperation {
operation := C.git_rebase_operation_byindex(rebase.ptr, C.size_t(index))
-
+
return newRebaseOperationFromC(operation)
}
@@ -165,7 +170,9 @@ func (rebase *Rebase) CurrentOperationIndex() (uint, error) {
// OperationCount gets the count of rebase operations that are to be applied.
func (rebase *Rebase) OperationCount() uint {
- return uint(C.git_rebase_operation_entrycount(rebase.ptr))
+ ret := uint(C.git_rebase_operation_entrycount(rebase.ptr))
+ runtime.KeepAlive(rebase)
+ return ret
}
// Next performs the next rebase operation and returns the information about it.
@@ -178,6 +185,7 @@ func (rebase *Rebase) Next() (*RebaseOperation, error) {
var ptr *C.git_rebase_operation
err := C.git_rebase_next(&ptr, rebase.ptr)
+ runtime.KeepAlive(rebase)
if err < 0 {
return nil, MakeGitError(err)
}
@@ -207,6 +215,8 @@ func (rebase *Rebase) Commit(ID *Oid, author, committer *Signature, message stri
defer C.free(unsafe.Pointer(cmsg))
cerr := C.git_rebase_commit(ID.toC(), rebase.ptr, authorSig, committerSig, nil, cmsg)
+ runtime.KeepAlive(ID)
+ runtime.KeepAlive(rebase)
if cerr < 0 {
return MakeGitError(cerr)
}
@@ -220,6 +230,7 @@ func (rebase *Rebase) Finish() error {
defer runtime.UnlockOSThread()
err := C.git_rebase_finish(rebase.ptr, nil)
+ runtime.KeepAlive(rebase)
if err < 0 {
return MakeGitError(err)
}
@@ -233,6 +244,7 @@ func (rebase *Rebase) Abort() error {
defer runtime.UnlockOSThread()
err := C.git_rebase_abort(rebase.ptr)
+ runtime.KeepAlive(rebase)
if err < 0 {
return MakeGitError(err)
}