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

Method Describe

describe.go:106–137  ·  view source on GitHub ↗

Describe performs the describe operation on the commit.

(opts *DescribeOptions)

Source from the content-addressed store, hash-verified

104
105// Describe performs the describe operation on the commit.
106func (c *Commit) Describe(opts *DescribeOptions) (*DescribeResult, error) {
107 var resultPtr *C.git_describe_result
108
109 var cDescribeOpts *C.git_describe_options
110 if opts != nil {
111 var cpattern *C.char
112 if len(opts.Pattern) > 0 {
113 cpattern = C.CString(opts.Pattern)
114 defer C.free(unsafe.Pointer(cpattern))
115 }
116
117 cDescribeOpts = &C.git_describe_options{
118 version: C.GIT_DESCRIBE_OPTIONS_VERSION,
119 max_candidates_tags: C.uint(opts.MaxCandidatesTags),
120 describe_strategy: C.uint(opts.Strategy),
121 pattern: cpattern,
122 only_follow_first_parent: cbool(opts.OnlyFollowFirstParent),
123 show_commit_oid_as_fallback: cbool(opts.ShowCommitOidAsFallback),
124 }
125 }
126
127 runtime.LockOSThread()
128 defer runtime.UnlockOSThread()
129
130 ecode := C.git_describe_commit(&resultPtr, c.ptr, cDescribeOpts)
131 runtime.KeepAlive(c)
132 if ecode < 0 {
133 return nil, MakeGitError(ecode)
134 }
135
136 return newDescribeResultFromC(resultPtr), nil
137}
138
139// DescribeWorkdir describes the working tree. It means describe HEAD
140// and appends <mark> (-dirty by default) if the working tree is dirty.

Callers 1

TestDescribeCommitFunction · 0.80

Calls 4

cboolFunction · 0.85
MakeGitErrorFunction · 0.85
newDescribeResultFromCFunction · 0.85
freeMethod · 0.80

Tested by 1

TestDescribeCommitFunction · 0.64