name | mode | size |
---|---|---|
.gitignore | 100644 | 0 kb |
.projectile | 100644 | |
LICENSE | 100644 | 1 kb |
README.org | 100644 | 4 kb |
branch.lisp | 100644 | 2 kb |
cl-git.asd | 100644 | 1 kb |
commit.lisp | 100644 | 1 kb |
delta.lisp | 100644 | 3 kb |
extract.lisp | 100644 | 4 kb |
git.lisp | 100644 | 5 kb |
graph.lisp | 100644 | 3 kb |
model.lisp | 100644 | 3 kb |
package.lisp | 100644 | 0 kb |
porcelain.lisp | 100644 | 4 kb |
protocol.lisp | 100644 | 1 kb |
repository.lisp | 100644 | 1 kb |
tree.lisp | 100644 | 2 kb |
undelta.lisp | 100644 | 1 kb |
util.lisp | 100644 | 2 kb |
* CL-GIT: the pure lisp interface to Git objects
** Introduction
Git libraries for Common Lisp common in a couple forms. Some attempt
to wrap the libgit2 git library
(e.g. https://github.com/russell/cl-git). Others wrap the git binary
in a subprocess (e.g. http://shinmera.github.io/legit/). Such
libraries work well in cases where you control the environment but
not all lisp programs run in such circumstances. This library, on the
contrary, attempts to implement parsers for git's file formats as well
as a thin "porcelain" interface for manipulating git objects.
** Installation
#+BEGIN_SRC sh
% git clone https://github.com/fiddlerwoaroof/fwoar.lisputils.git "$HOME/quicklisp/local-projects/fwoar-lisputils"
% git clone https://github.com/fiddlerwoaroof/cl-git.git "$HOME/quicklisp/local-projects/cl-git"
% sbcl --load "$HOME/quicklisp/setup.lisp"
CL-USER> (ql:quickload :cl-git)
#+END_SRC
** Example usage
*** Get the commit id of the master branch for a specific repository:
#+BEGIN_SRC lisp :exports both :results verbatim
(git:in-repository "~/quicklisp/local-projects/cl-git")
(git:git (branch "master")) ;; the argument to branch defaults to "master"
#+END_SRC
#+RESULTS:
: #<LOOSE-REF 4d4ea31 of ~/git_repos/cl-git/>
*** Show the commit message
#+BEGIN_SRC lisp :exports both :results verbatim
(git:in-repository "~/quicklisp/local-projects/cl-git")
(git:git (branch "master") ;; the argument to branch defaults to "master"
(component :message))
#+END_SRC
#+RESULTS:
: doc: Complete installation instruction
*** Show the messages of the commit's parent
#+BEGIN_SRC lisp :exports both :results verbatim
(git:in-repository "~/quicklisp/local-projects/cl-git")
(git:git (branch "master") ;; the argument to branch defaults to "master"
(commit-parents))
#+END_SRC
#+RESULTS:
: (("7df80f061ae5bf6177a1c0888d085281be2801e1"))
*** Show the files in a commit
#+BEGIN_SRC lisp :exports both :results table :hlines yes
(git:in-repository "~/quicklisp/local-projects/cl-git")
(list* #("name" "mode" "hash")
(git:git (branch "master")
(component :tree :entries)
(map (juxt (component :name)
(component :mode)
(component :hash)))))
#+END_SRC
#+RESULTS:
| name | mode | hash |
| .gitignore | 100644 | 8a9fe9f77149f74fed5c05388be8e5ffd4a31678 |
| .projectile | 100644 | e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 |
| LICENSE | 100644 | 0306819e780fa57dc3bf6b99a0a059670b605ae0 |
| README.org | 100644 | a52be677adeda194bcdfdd12740f00535b6b0997 |
| branch.lisp | 100644 | e06b66967fa4fa005ccf00dcbc7d839b22259593 |
| cl-git.asd | 100644 | 9db42f61f21e11529b9bc1c52ee118c03d663c04 |
| extract.lisp | 100644 | cf8e6e10786a26ffcd6a3e0fdb97abdf1c9f0345 |
| git.lisp | 100644 | c516dfc248544509c3ae58e3a8c2ab81c225aa9c |
| graph.lisp | 100644 | 31576396aff0fff28f69e0ef84571c0dc8cc43ec |
| model.lisp | 100644 | fb265bb344fee602dc175d1d5eac6bdc2d013a10 |
| package.lisp | 100644 | d2818bb88b8ec5235a8ae91309f31ba58d941d42 |
| porcelain.lisp | 100644 | 0673dcbe10b945d561a9c3c485fe28aab12b257c |
| undelta.lisp | 100644 | ae0a070133d1a14d6e940a0f790f40b37e885b22 |
| util.lisp | 100644 | 87c2b9b2dfaa1fbf66b3fe88d3a925593886b159 |
** Partially Implemented:
*** Delta refs
Git uses a [[https://git-scm.com/docs/pack-format#_deltified_representation][delta calculation]] routine to compress some of the blobs
in a pack file. This delta stores a reference to a base object and
a sequence of commands for transforming the base object into the
new object. My plan to support this is to first just extract the
commands from the pack file and store them as a [[file:delta.lisp::(defclass delta () ((%repository :initarg :repository :reader repository) (%base :initarg :base :reader base) (%commands :initarg :commands :reader commands)))][delta object]]. When
this works adequately, I'll write an interpreter to do the actual
merge.