(ids []*Oid, minlen int)
| 262 | } |
| 263 | |
| 264 | func 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 | |
| 289 | type GitError struct { |
| 290 | Message string |
nothing calls this directly
no test coverage detected
searching dependent graphs…