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

Function ShortenOids

git.go:264–287  ·  view source on GitHub ↗
(ids []*Oid, minlen int)

Source from the content-addressed store, hash-verified

262}
263
264func ShortenOids(ids []*Oid, minlen int) (int, error) {
265 shorten := C.git_oid_shorten_new(C.size_t(minlen))
266 if shorten == nil {
267 panic("Out of memory")
268 }
269 defer C.git_oid_shorten_free(shorten)
270
271 var ret C.int
272
273 runtime.LockOSThread()
274 defer runtime.UnlockOSThread()
275
276 for _, id := range ids {
277 buf := make([]byte, 41)
278 C.git_oid_fmt((*C.char)(unsafe.Pointer(&buf[0])), id.toC())
279 buf[40] = 0
280 ret = C.git_oid_shorten_add(shorten, (*C.char)(unsafe.Pointer(&buf[0])))
281 if ret < 0 {
282 return int(ret), MakeGitError(ret)
283 }
284 }
285 runtime.KeepAlive(ids)
286 return int(ret), nil
287}
288
289type GitError struct {
290 Message string

Callers

nothing calls this directly

Calls 2

MakeGitErrorFunction · 0.85
toCMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…