You are looking at historical revision 25333 of this page. It may differ significantly from its current revision.

git

Description

Bindings to the libgit2 library.

Please note that the libgit library is currently a moving target, under heavy development. This library has been written and tested against libgit2 0.13.0. If you encounter problems, check your versions.

Documentation

git provides an interface for reading & manipulating git repositories. The library is split into two modules, git and git-lolevel:

The following documentation applies to the git module.

Usage

 (use git)

or

 (use git-lolevel)

It's not recommended to mix the two without prefixing one or the other's imports, as the two libraries share many identifiers.

API

Repository

[record] repository
[procedure] (repository-open [path]) => repository
[procedure] (repository-path repository [type]) => string
[procedure] (repository-ref repository ref) => object
[procedure] (repository-empty? repository) => boolean
[procedure] (repository-bare? repositoy) => boolean
[procedure] (pack-references repository) => void

OID

[record] oid
[procedure] (string->oid string) => oid
[procedure] (oid->string oid [length]) => string
[procedure] (oid->path oid) => string

Reference

[record] reference
[procedure] (reference repository ref) => reference
[procedure] (references repository) => list
[procedure] (reference-id reference) => oid
[procedure] (reference-owner reference) => repository
[procedure] (reference-resolve reference) => reference
[procedure] (reference-id-set reference oid) => void
[procedure] (reference-rename reference name) => void
[procedure] (reference-target-set reference target) => void
[procedure] (create-reference repository name target [symbolic?]) => reference

Generic

[procedure] (object-id object) => oid
[procedure] (object-sha object [length]) => string
[procedure] (object-type object) => symbol

Blob*

[record] blob*
[procedure] (blob* repository ref) => blob*
[procedure] (blob*-content blob) => blob
[procedure] (blob*-size blob) => int

Commit

[record] commit
[procedure] (commit repository ref) => commit
[procedure] (commits repository initial [hide] [sort]) => list
[procedure] (commit-id commit) => oid
[procedure] (commit-parentcount commit) => int
[procedure] (commit-time commit) => int
[procedure] (commit-time-offset commit) => int
[procedure] (commit-message commit) => string
[procedure] (commit-message-short commit) => string
[procedure] (commit-tree commit) => tree
[procedure] (commit-author commit) => signature
[procedure] (commit-committer commit) => signature
[procedure] (commit-parent commit [n]) => commit
[procedure] (create-commit repository tree message [parents] author [committer] [reference]) => commit

Tag

[record] tag
[procedure] (tag repository name) => tag
[procedure] (tags repository) => list
[procedure] (tag-id tag) => oid
[procedure] (tag-type tag) => symbol
[procedure] (tag-name tag) => string
[procedure] (tag-message tag) => string
[procedure] (tag-tagger tag) => signature
[procedure] (tag-target tag) => object
[procedure] (tag-delete tag) => tag
[procedure] (create-tag repository target name message tagger) => tag

Tree

[record] tree
[procedure] (tree repository ref) => tree
[procedure] (tree-id tree) => oid
[procedure] (tree-entrycount tree) => int
[procedure] (tree-ref tree key) => tree-entry
[procedure] (tree->list tree [repo]) => list
[procedure] (create-tree repository index) => tree

Tree Entry

[record] tree-entry
[procedure] (tree-entry-id tree-entry) => oid
[procedure] (tree-entry-name tree-entry) => string
[procedure] (tree-entry-attributes tree-entry) => int
[procedure] (tree-entry-type tree-entry) => symbol
[procedure] (tree-entry->object repository tree-entry) => object

Index

[record] index
[procedure] (index-open repo-or-path) => index
[procedure] (index-entrycount index) => int
[procedure] (index-entrycount-unmerged index) => int
[procedure] (index-read index) => void
[procedure] (index-write index) => void
[procedure] (index-clear index) => void
[procedure] (index-add index path [stage]) => void
[procedure] (index-remove index ref) => void
[procedure] (index-find index) => int
[procedure] (index-ref index key) => index-entry
[procedure] (index->list index [type]) => list

Index Entry

[record] index-entry
[procedure] (index-entry-id index-entry) => oid
[procedure] (index-entry-path index-entry) => string
[procedure] (index-entry-ctime index-entry) => int
[procedure] (index-entry-mtime index-entry) => int
[procedure] (index-entry-dev index-entry) => int
[procedure] (index-entry-ino index-entry) => int
[procedure] (index-entry-size index-entry) => int
[procedure] (index-entry-stage index-entry) => int
[procedure] (index-entry-uid index-entry) => int
[procedure] (index-entry-gid index-entry) => int
[procedure] (index-entry-mode index-entry) => int
[procedure] (index-entry-flags index-entry) => int
[procedure] (index-entry-extended index-entry) => int
[procedure] (index-entry->object repository index-entry) => object

ODB

[procedure] (odb-new) => odb
[procedure] (odb-open repo-or-path) => odb
[procedure] (odb-has-object? odb ref) => boolean
[procedure] (odb-read odb ref) => odb-object
[procedure] (odb-write odb data [type]) => oid
[procedure] (odb-hash odb data [type]) => oid

ODB Object

[record] odb-object
[procedure] (odb-object-id odb-object) => oid
[procedure] (odb-object-size odb-object) => int
[procedure] (odb-object-type odb-object) => symbol
[procedure] (odb-object-data odb-object) => blob

Signature

[record] signature
[procedure] (make-signature name email [time] [offset]) => signature
[procedure] (signature-name signature) => string
[procedure] (signature-email signature) => string
[procedure] (signature-time signature) => int
[procedure] (signature-time-offset signature) => int

Author

Evan Hanson

License

Copyright (c) 2011, Evan Hanson, 3-Clause BSD License