Objects

Accessing

generic (get-object class id/name repository)

generic (list-objects class repository &key test test-not)

Specializers:
((eql :oid) repository)
(remote common-lisp:t)
(tag common-lisp:t)
((eql :oid) odb)
(reference common-lisp:t)

Note that although we are looking up a commit we specify as class OBJECT. The advantage of specifying OBJECT instead of COMMIT is that you do not need to know that the SHA refers to a commit. If the SHA refers to a tag a tag will be returned.

However if we do not know the SHA-1 but we do know a reference, such as a branch name or tag. We can get to the commit in a slightly more cumbersome way. (A list of references is easy to get, see the previous section.)

Inspecting

generic (oid object)

Return the identifier of OBJECT. The identifier is typically the SHA-1 checksum or hash code.

Note that this is an integer, and not the string you typically see reported by git.

To get the string representation use format like this:

(format nil "~40,'0X" (oid object))

or if you want lowercase hexadecimal digits:

(format nil "~(~40,'0X~)" (oid object))
Specializers:
(reference)
(odb-object)
(git-object)

generic (full-name object)

Returns the name of OBJECT, as a string.

What exactly the name is depends on the type of the object.

Specializers:
(reference)
(remote)
(tag)
(git-object)

generic (short-name object)

Returns the short name of OBJECT, as a string.

What exactly the name is depends on the type of the object.

Specializers:
(reference)
(remote)
(tag)
(git-object)

Errors

type git-error

type not-found

type exists

type ambiguous-error

type buffer-error

type user-error

type barerepo-error

type orphanedhead-error

type unmerged-error

type non-fast-forward-error

type invalid-spec-error

type merge-conflict-error

Error conditions can be raised from libgit2 and will be converted into conditions instead of returning NIL values.

GIT> (get-object 'object 1
                 (open-repository #p"/home/russell/projects/ecl/"))
; Raises NOT-FOUND condition

For each of the possible libgit2 errors there is a different condition that will be raised.