@@ -27,6 +27,15 @@ func newAnnotatedCommitFromC(ptr *C.git_annotated_commit, r *Repository) *Annota
27
27
return mh
28
28
}
29
29
30
+ func (mh * AnnotatedCommit ) Id () * Oid {
31
+ runtime .LockOSThread ()
32
+ defer runtime .UnlockOSThread ()
33
+
34
+ ret := newOidFromC (C .git_annotated_commit_id (mh .ptr ))
35
+ runtime .KeepAlive (mh )
36
+ return ret
37
+ }
38
+
30
39
func (mh * AnnotatedCommit ) Free () {
31
40
runtime .SetFinalizer (mh , nil )
32
41
C .git_annotated_commit_free (mh .ptr )
@@ -49,7 +58,9 @@ func (r *Repository) AnnotatedCommitFromFetchHead(branchName string, remoteURL s
49
58
return nil , MakeGitError (ret )
50
59
}
51
60
52
- return newAnnotatedCommitFromC (ptr , r ), nil
61
+ annotatedCommit := newAnnotatedCommitFromC (ptr , r )
62
+ runtime .KeepAlive (r )
63
+ return annotatedCommit , nil
53
64
}
54
65
55
66
func (r * Repository ) LookupAnnotatedCommit (oid * Oid ) (* AnnotatedCommit , error ) {
@@ -62,7 +73,10 @@ func (r *Repository) LookupAnnotatedCommit(oid *Oid) (*AnnotatedCommit, error) {
62
73
if ret < 0 {
63
74
return nil , MakeGitError (ret )
64
75
}
65
- return newAnnotatedCommitFromC (ptr , r ), nil
76
+
77
+ annotatedCommit := newAnnotatedCommitFromC (ptr , r )
78
+ runtime .KeepAlive (r )
79
+ return annotatedCommit , nil
66
80
}
67
81
68
82
func (r * Repository ) AnnotatedCommitFromRef (ref * Reference ) (* AnnotatedCommit , error ) {
@@ -76,7 +90,29 @@ func (r *Repository) AnnotatedCommitFromRef(ref *Reference) (*AnnotatedCommit, e
76
90
if ret < 0 {
77
91
return nil , MakeGitError (ret )
78
92
}
79
- return newAnnotatedCommitFromC (ptr , r ), nil
93
+
94
+ annotatedCommit := newAnnotatedCommitFromC (ptr , r )
95
+ runtime .KeepAlive (r )
96
+ return annotatedCommit , nil
97
+ }
98
+
99
+ func (r * Repository ) AnnotatedCommitFromRevspec (spec string ) (* AnnotatedCommit , error ) {
100
+ crevspec := C .CString (spec )
101
+ defer C .free (unsafe .Pointer (crevspec ))
102
+
103
+ runtime .LockOSThread ()
104
+ defer runtime .UnlockOSThread ()
105
+
106
+ var ptr * C.git_annotated_commit
107
+ ret := C .git_annotated_commit_from_revspec (& ptr , r .ptr , crevspec )
108
+ runtime .KeepAlive (r )
109
+ if ret < 0 {
110
+ return nil , MakeGitError (ret )
111
+ }
112
+
113
+ annotatedCommit := newAnnotatedCommitFromC (ptr , r )
114
+ runtime .KeepAlive (r )
115
+ return annotatedCommit , nil
80
116
}
81
117
82
118
type MergeTreeFlag int
0 commit comments