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

Method DescribeWorkdir

describe.go:141–172  ·  view source on GitHub ↗

DescribeWorkdir describes the working tree. It means describe HEAD and appends (-dirty by default) if the working tree is dirty.

(opts *DescribeOptions)

Source from the content-addressed store, hash-verified

139// DescribeWorkdir describes the working tree. It means describe HEAD
140// and appends <mark> (-dirty by default) if the working tree is dirty.
141func (repo *Repository) DescribeWorkdir(opts *DescribeOptions) (*DescribeResult, error) {
142 var resultPtr *C.git_describe_result
143
144 var cDescribeOpts *C.git_describe_options
145 if opts != nil {
146 var cpattern *C.char
147 if len(opts.Pattern) > 0 {
148 cpattern = C.CString(opts.Pattern)
149 defer C.free(unsafe.Pointer(cpattern))
150 }
151
152 cDescribeOpts = &C.git_describe_options{
153 version: C.GIT_DESCRIBE_OPTIONS_VERSION,
154 max_candidates_tags: C.uint(opts.MaxCandidatesTags),
155 describe_strategy: C.uint(opts.Strategy),
156 pattern: cpattern,
157 only_follow_first_parent: cbool(opts.OnlyFollowFirstParent),
158 show_commit_oid_as_fallback: cbool(opts.ShowCommitOidAsFallback),
159 }
160 }
161
162 runtime.LockOSThread()
163 defer runtime.UnlockOSThread()
164
165 ecode := C.git_describe_workdir(&resultPtr, repo.ptr, cDescribeOpts)
166 runtime.KeepAlive(repo)
167 if ecode < 0 {
168 return nil, MakeGitError(ecode)
169 }
170
171 return newDescribeResultFromC(resultPtr), nil
172}
173
174// DescribeResult represents the output from the 'git_describe_commit'
175// and 'git_describe_workdir' functions in libgit2.

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