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

Function NewOid

git.go:219–237  ·  view source on GitHub ↗
(s string)

Source from the content-addressed store, hash-verified

217}
218
219func NewOid(s string) (*Oid, error) {
220 if len(s) > C.GIT_OID_HEXSZ {
221 return nil, errors.New("string is too long for oid")
222 }
223
224 o := new(Oid)
225
226 slice, err := hex.DecodeString(s)
227 if err != nil {
228 return nil, err
229 }
230
231 if len(slice) != 20 {
232 return nil, &GitError{"invalid oid", ErrorClassNone, ErrorCodeGeneric}
233 }
234
235 copy(o[:], slice[:20])
236 return o, nil
237}
238
239func (oid *Oid) String() string {
240 return hex.EncodeToString(oid[:])

Callers 9

TestReachableFromAnyFunction · 0.85
TestEmptyOidFunction · 0.85
TestTreeEntryByIdFunction · 0.85
TestTreeWalkFunction · 0.85
TestTreeWalkSkipFunction · 0.85
TestTreeWalkStopFunction · 0.85
TestMempackFunction · 0.85
TestOdbStreamFunction · 0.85
TestOdbBackendLooseFunction · 0.85

Calls

no outgoing calls

Tested by 9

TestReachableFromAnyFunction · 0.68
TestEmptyOidFunction · 0.68
TestTreeEntryByIdFunction · 0.68
TestTreeWalkFunction · 0.68
TestTreeWalkSkipFunction · 0.68
TestTreeWalkStopFunction · 0.68
TestMempackFunction · 0.68
TestOdbStreamFunction · 0.68
TestOdbBackendLooseFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…