2.25 Object
(require libgit2/include/object) | package: libgit2 |
procedure
(git_object__size type) → integer?
type : git_otype
For all the core types, this would the equivalent of calling sizeof(git_commit) if the core types were not opaque on the external API.
This method instructs the library to close an existing object; note that git_objects are owned and cached by the repository so the object may or may not be freed after this library call, depending on how aggressive is the caching mechanism used by the repository.
IMPORTANT: It is necessary to call this method when you stop using an object. Failure to do so will cause a memory leak.
procedure
(git_object_lookup repo id type) → object?
repo : repository? id : oid? type : git_otype
The generated reference is owned by the repository and should be closed with the git_object_free method instead of free’d manually.
The ’type’ parameter must match the type of the object in the odb; the method will fail otherwise. The special value ’GIT_OBJ_ANY’ may be passed to let the method guess the object’s type.
procedure
(git_object_lookup_bypath treeish path type) → object?
treeish : object? path : string? type : git_otype
procedure
(git_object_lookup_prefix repo id len type) → object?
repo : repository? id : oid? len : integer? type : git_otype
The object obtained will be so that its identifier matches the first ’len’ hexadecimal characters (packets of 4 bits) of the given ’id’. ’len’ must be at least GIT_OID_MINPREFIXLEN, and long enough to identify a unique object matching the prefix; otherwise the method will fail.
The generated reference is owned by the repository and should be closed with the git_object_free method instead of free’d manually.
The ’type’ parameter must match the type of the object in the odb; the method will fail otherwise. The special value ’GIT_OBJ_ANY’ may be passed to let the method guess the object’s type.
procedure
obj : object?
Freeing or calling git_repository_close on the returned pointer will invalidate the actual object.
Any other operation may be run on the repository without affecting the object.
If the query cannot be satisfied due to the object model, GIT_EINVALIDSPEC will be returned (e.g. trying to peel a blob to a tree).
If you pass GIT_OBJ_ANY as the target type, then the object will be peeled until the type changes. A tag will be peeled until the referenced object is no longer a tag, and a commit will be peeled to a tree. Any other object type will return GIT_EINVALIDSPEC.
If peeling a tag we discover an object which cannot be peeled to the target type due to the object model, GIT_EPEEL will be returned.
You must free the returned object.
This starts at the "core.abbrev" length (default 7 characters) and iteratively extends to a longer string if that length is ambiguous. The result will be unambiguous (at least until new objects are added to the repository).
procedure
str : string?
procedure
obj : object?
procedure
(git_object_type2string type) → string?
type : git_otype
The result is a pointer to a string in static memory and should not be free()’ed.
procedure
(git_object_typeisloose type) → boolean?
type : git_otype