Repositories

type repository

Repository is the root type, it contains the object database.

Creating

generic (init-repository path/name &key bare)

Create a new Git repository. PATH/NAME can be either an instance of a STRING or a PATHNAME. A truthful value for the key BARE will init a repository that does not have a local checkout, it's normally appropriate for the basename of the path to end in '.git'. A REPOSITORY instance is returned.

GIT> (init-repository #p"/tmp/test-repo/")
#<REPOSITORY 7FFFE8006800 {1005F3CE43}>
Specializers:
(common-lisp:string)
(common-lisp:pathname)

method (empty-p (repository repository))

Return T if the repository is empty and contains no references.

GIT> (empty-p (open-repository #p"/tmp/test-repo/"))
T
Specializers:
(repository)

Bare

Bare repositories can be created by passing a truthful value to the key argument BARE when initialising a repository.

GIT> (init-repository #p"/tmp/test-bare/" :bare t)
#<REPOSITORY 7FFFE8008CD0 {10062DE723}>

Whether an existing repository is bare can be determined using the bare-p method.

method (bare-p (repository repository))

Return T if the repository is bare.

GIT> (bare-p (open-repository #p"/tmp/test-bare/"))
T
Specializers:
(repository)

Accessing

method (open-repository path/name)

Open an existing repository located at PATH/NAME. The repository object will be garbage collected. If it's freed explicitly then all related objects will have undefined behaviour.

GIT> (open-repository #p"/home/russell/projects/ecl/")
#<REPOSITORY 7FFFE8003E00 {1004CCDBA3}>
GIT> (open-repository "/home/russell/projects/ecl/")
#<REPOSITORY 7FFFE8004000 {1004D617F3}>
Specializers:
(common-lisp:string)
(common-lisp:pathname)

macro (with-repository (var pathname-or-string) &body body)

Evaluates the body with VAR bound to a newly opened located repository at PATHNAME-OR-STRING. Repository is freed upon exit of this scope so any objects that leave this scope will no longer be able to access the repository.

Parameters:
pathname-or-string -- the location of the repository.
path -- the path to the git repository.
body -- the body of the macro.
CL-GIT> (with-repository (repository #p"/home/russell/projects/ecl/")
          (prin1 repository)
          nil)
#<REPOSITORY 7FFFE8003E00 {1003880DA3}>
NIL

Path

method (repository-path (object repository))

Returns the path the the .git directory of the repository. For a bare repository to the repository itself.

Specializers:
(repository)

method (repository-workdir (object repository))

Returns the working directory for the repository. This is the directory that files are checked out into.

Specializers:
(repository)

Status

function (repository-status repository)

Return the current status values for each of the object in the repository. For each element of the list the FIRST is the name of the file and the CDR is a list of keywords that containing the current state of the file. Possible states are: :CURRENT :INDEX-NEW :INDEX-MODIFIED :INDEX-DELETED :INDEX-RENAMED :INDEX-TYPECHANGE :WORKTREE-NEW :WORKTREE-MODIFIED :WORKTREE-DELETED :WORKTREE-TYPECHANGE or :IGNORED

CL-GIT> (with-repository (repository #p"/home/russell/projects/lisp/cl-git/")
           (repository-status repository))

(("src/status.lisp" :CURRENT :WORKTREE-MODIFIED)
 ("src/package.lisp" :CURRENT :WORKTREE-MODIFIED)
 ("fabfile.pyc" :CURRENT :IGNORED)
 ("doc/repositories.rst" :CURRENT :WORKTREE-MODIFIED)
 ("doc/cl-git.html" :CURRENT :WORKTREE-NEW)
 ("doc/.installed.cfg" :CURRENT :IGNORED))

Configuration

Configuration details of a particular repository can be done with the GIT-CONFIG method.

method (git-config (object repository) &key level)

Open a git config. LEVEL can be used to limit the git config to a specific level. Possible levels are :HIGHEST-LEVEL :SYSTEM :XDG :GLOBAL or :LOCAL

Specializers:
(config)
(repository)