summaryrefslogtreecommitdiff
path: root/merge.go
diff options
context:
space:
mode:
authorlhchavez <[email protected]>2020-02-23 14:58:21 +0000
committerlhchavez <[email protected]>2020-02-23 14:58:21 +0000
commita140f2310f56eb06d37454514e67647a8a49d197 (patch)
treefb156488aa27d753c7fe7864b9917a48d027b38e /merge.go
parent627447092fa24035ed3cd4cf31932dbef6f5a57f (diff)
Add test and runtime.KeepAlive()
Diffstat (limited to 'merge.go')
-rw-r--r--merge.go19
1 files changed, 15 insertions, 4 deletions
diff --git a/merge.go b/merge.go
index ab30fb2..06e98a0 100644
--- a/merge.go
+++ b/merge.go
@@ -58,7 +58,9 @@ func (r *Repository) AnnotatedCommitFromFetchHead(branchName string, remoteURL s
return nil, MakeGitError(ret)
}
- return newAnnotatedCommitFromC(ptr, r), nil
+ annotatedCommit := newAnnotatedCommitFromC(ptr, r)
+ runtime.KeepAlive(r)
+ return annotatedCommit, nil
}
func (r *Repository) LookupAnnotatedCommit(oid *Oid) (*AnnotatedCommit, error) {
@@ -71,7 +73,10 @@ func (r *Repository) LookupAnnotatedCommit(oid *Oid) (*AnnotatedCommit, error) {
if ret < 0 {
return nil, MakeGitError(ret)
}
- return newAnnotatedCommitFromC(ptr, r), nil
+
+ annotatedCommit := newAnnotatedCommitFromC(ptr, r)
+ runtime.KeepAlive(r)
+ return annotatedCommit, nil
}
func (r *Repository) AnnotatedCommitFromRef(ref *Reference) (*AnnotatedCommit, error) {
@@ -85,7 +90,10 @@ func (r *Repository) AnnotatedCommitFromRef(ref *Reference) (*AnnotatedCommit, e
if ret < 0 {
return nil, MakeGitError(ret)
}
- return newAnnotatedCommitFromC(ptr, r), nil
+
+ annotatedCommit := newAnnotatedCommitFromC(ptr, r)
+ runtime.KeepAlive(r)
+ return annotatedCommit, nil
}
func (r *Repository) AnnotatedCommitFromRevspec(spec string) (*AnnotatedCommit, error) {
@@ -101,7 +109,10 @@ func (r *Repository) AnnotatedCommitFromRevspec(spec string) (*AnnotatedCommit,
if ret < 0 {
return nil, MakeGitError(ret)
}
- return newAnnotatedCommitFromC(ptr, r), nil
+
+ annotatedCommit := newAnnotatedCommitFromC(ptr, r)
+ runtime.KeepAlive(r)
+ return annotatedCommit, nil
}
type MergeTreeFlag int