Objects

Creating

Generic (make-object class id/name repository &key url type force target signature message log-message &allow-other-keys)
(make-object (class (eq REFERENCE)) (name T) (repository T) &KEY (TYPE :OID) FORCE TARGET SIGNATURE (LOG-MESSAGE ""))
(make-object (class (eq BRANCH)) (name T) (repository T) &KEY TARGET FORCE)
(make-object (class (eq TAG)) (name T) (repository T) &KEY (TYPE :ANNOTATED) FORCE TARGET SIGNATURE MESSAGE)
(make-object (class (eq REMOTE)) (name T) (repository T) &KEY URL)

Create objects within a Git repository, Please see the documentation for each implementing method.

Accessing

Generic (get-object class id/name repository)
(get-object (class (eq OBJECT)) (oid T) (repository T))
(get-object (class (eq BLOB)) (oid T) (repository T))
(get-object (class (eq TREE)) (oid T) (repository T))
(get-object (class (eq COMMIT)) (oid T) (repository T))
(get-object (class (eq COMMIT)) (commit COMMIT) (repository T))
(get-object (class (eq REFERENCE)) (name T) (repository T))
(get-object (class (eq TAG)) (name-or-oid T) (repository T))
(get-object (class (eq REMOTE)) (name T) (repository T))
(get-object (class (eq ODB-OBJECT)) (oid T) (odb ODB))
(get-object (class (eq ODB-OBJECT)) (oid T) (repository REPOSITORY))

Return an object of type CLASS from the object database. The lookup will use either an oid or a name to find the object.

Generic (list-objects class repository &key test test-not)
(list-objects (class (eq REFERENCE)) (repository T) &KEY TEST TEST-NOT)
(list-objects (class (eq TAG)) (repository T) &KEY TEST TEST-NOT)
(list-objects (class (eq REMOTE)) (repository T) &KEY TEST TEST-NOT)
(list-objects (class (eq :OID)) (repository ODB) &KEY TEST TEST-NOT)
(list-objects (class (eq :OID)) (repository REPOSITORY) &KEY TEST TEST-NOT)

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.)

Deleting

Generic (delete-object object)
(delete-object (reference REFERENCE))

Delete objects within a Git repository, Please see the documentation for each implementing method.

Inspecting

Generic (oid object)
(oid (object CL-GIT::GIT-OBJECT))
(oid (reference REFERENCE))
(oid (object ODB-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))

Generic (full-name object)
(full-name (object CL-GIT::GIT-OBJECT))
(full-name (object REFERENCE))
(full-name (tag TAG))
(full-name (remote REMOTE))

Returns the name of OBJECT, as a string.

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

Generic (short-name object)
(short-name (object CL-GIT::GIT-OBJECT))
(short-name (object REFERENCE))
(short-name (tag TAG))
(short-name (remote REMOTE))

Returns the short name of OBJECT, as a string.

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

Errors

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.

CLOS class basic-error
Superclass:

[‘T’]

Metaclass:

sb-pcl::condition-class

Initargs:
CLOS slot class
Type:

sb-pcl::condition-direct-slot-definition

Initarg:

:class

Reader:

(cl-git::error-class (object basic-error))

Writer:

(setf (cl-git::error-class (object basic-error)) (new-value T))

The error code/class returned by git_lasterr.

CLOS slot cl-git::code
Type:

sb-pcl::condition-direct-slot-definition

Initarg:

:code

Reader:

(cl-git::error-code (object basic-error))

Writer:

(setf (cl-git::error-code (object basic-error)) (new-value T))

The error value returned by a function.

CLOS slot message
Type:

sb-pcl::condition-direct-slot-definition

Initarg:

:message

Reader:

(cl-git::error-message (object basic-error))

Writer:

(setf (cl-git::error-message (object basic-error)) (new-value T))

Text message indicating what went wrong.

CLOS class general-error
Superclass:

[‘T’]

Metaclass:

sb-pcl::condition-class

Generic error

CLOS class not-found-error
Superclass:

[‘T’]

Metaclass:

sb-pcl::condition-class

Requested object could not be found

CLOS class exists-error
Superclass:

[‘T’]

Metaclass:

sb-pcl::condition-class

Object exists preventing operation

CLOS class ambiguous-error
Superclass:

[‘T’]

Metaclass:

sb-pcl::condition-class

More than one object matches

CLOS class buffer-error
Superclass:

[‘T’]

Metaclass:

sb-pcl::condition-class

Output buffer too short to hold data

CLOS class user-error
Superclass:

[‘T’]

Metaclass:

sb-pcl::condition-class

GIT_EUSER is a special error that is never generated by libgit2 code. You can return it from a callback (e.g to stop an iteration) to know that it was generated by the callback and not by libgit2.

CLOS class barerepo-error
Superclass:

[‘T’]

Metaclass:

sb-pcl::condition-class

Operation not allowed on bare repository

CLOS class unborn-branch-error
Superclass:

[‘T’]

Metaclass:

sb-pcl::condition-class

HEAD refers to branch with no commits

CLOS class unmerged-error
Superclass:

[‘T’]

Metaclass:

sb-pcl::condition-class

Merge in progress prevented operation

CLOS class non-fast-forward-error
Superclass:

[‘T’]

Metaclass:

sb-pcl::condition-class

Reference was not fast-forwardable

CLOS class invalid-spec-error
Superclass:

[‘T’]

Metaclass:

sb-pcl::condition-class

Name/ref spec was not in a valid format

CLOS class conflict-error
Superclass:

[‘T’]

Metaclass:

sb-pcl::condition-class

Checkout conflicts prevented operation

CLOS class locked-error
Superclass:

[‘T’]

Metaclass:

sb-pcl::condition-class

Lock file prevented operation

CLOS class modified-error
Superclass:

[‘T’]

Metaclass:

sb-pcl::condition-class

Reference value does not match expected

CLOS class auth-error
Superclass:

[‘T’]

Metaclass:

sb-pcl::condition-class

Authentication error

CLOS class certificate-error
Superclass:

[‘T’]

Metaclass:

sb-pcl::condition-class

Server certificate is invalid

CLOS class applied-error
Superclass:

[‘T’]

Metaclass:

sb-pcl::condition-class

Patch/merge has already been applied

CLOS class peel-error
Superclass:

[‘T’]

Metaclass:

sb-pcl::condition-class

The requested peel operation is not possible

CLOS class eof-error
Superclass:

[‘T’]

Metaclass:

sb-pcl::condition-class

Unexpected EOF

CLOS class invalid-error
Superclass:

[‘T’]

Metaclass:

sb-pcl::condition-class

Invalid operation or input

CLOS class uncommitted-error
Superclass:

[‘T’]

Metaclass:

sb-pcl::condition-class

Uncommitted changes in index prevented operation

CLOS class directory-error
Superclass:

[‘T’]

Metaclass:

sb-pcl::condition-class

The operation is not valid for a directory

CLOS class merge-conflict-error
Superclass:

[‘T’]

Metaclass:

sb-pcl::condition-class

A merge conflict exists and cannot continue

CLOS class mismatch-error
Superclass:

[‘T’]

Metaclass:

sb-pcl::condition-class

Hashsum mismatch in object

CLOS class index-dirty-error
Superclass:

[‘T’]

Metaclass:

sb-pcl::condition-class

Unsaved changes in the index would be overwritten

CLOS class apply-fail-error
Superclass:

[‘T’]

Metaclass:

sb-pcl::condition-class

Patch application failedq

Control Flow Errors

CLOS class passthrough
Superclass:

[‘T’]

Metaclass:

sb-pcl::condition-class

A user-configured callback refused to act

CLOS class stop-iteration
Superclass:

[‘T’]

Metaclass:

sb-pcl::condition-class

Signals end of iteration with iterator

CLOS class retry
Superclass:

[‘T’]

Metaclass:

sb-pcl::condition-class

Internal only