Commits ======= .. cl:package:: cl-git .. cl:clos-class:: commit Creating -------- .. cl:function:: make-commit Accessing --------- There are a few ways to find commits in the repository, the easiest is to find a commit when we know the SHA-1 has. In that case the process is as follows: .. code-block:: common-lisp-repl GIT> (get-object 'commit "15b8410814ec05d63b85c5e4b735dcdc77719a08" (open-repository #p"/home/russell/projects/ecl/")) # To get access to a single reference. .. code-block:: common-lisp-repl GIT> (get-object 'reference "refs/heads/master" (open-repository "/home/russell/projects/ecl/")) # However to get from a reference to a commit is easy using the :cl:symbol:`TARGET` method. .. code-block:: common-lisp-repl GIT> (target (get-object 'reference "refs/heads/master" (open-repository "/home/russell/projects/ecl/"))) # In this case we ended up with a commit, however a reference can refer to any object in the git database, so tags, blobs and trees are also possible. Now in normal use you do not see references to blobs or trees very frequently, but references to tags are more common. So in normal code you have to check for that and act accordingly. .. cl:method:: get-object (eq commit) common-lisp:t common-lisp:t .. cl:macro:: bind-git-commits Iterating ~~~~~~~~~ .. cl:function:: revision-walk .. cl:generic:: next-revision To walk commits, :cl:symbol:`REVISION-WALK` and :cl:symbol:`NEXT-REVISION` are provided. .. code-block:: common-lisp-repl GIT> (let ((repository (open-repository (merge-pathnames #p"projects/ecl" (user-homedir-pathname))))) (loop :with walker = (revision-walk (get-object 'commit "ea010dee347e50666331b77edcf0588735c3205a" repository)) :for revision = (next-revision walker) :until (null revision) :collect revision)) (# # # # #) Inspecting ---------- .. cl:generic:: message .. code-block:: common-lisp-repl GIT> (message (get-object 'commit "ea010dee347e50666331b77edcf0588735c3205a" (open-repository #p"/home/russell/projects/ecl/"))) "Add new declaration, si::c-export-fname, which produces lisp compiled files with meaningful names for the exported functions. For instance, (proclaim '(si::c-export-fname union)) is used to produce a C function with name clLunion, which can be directly used in other compiled files. This feature has been applied to almost all functions in the Lisp runtime. " .. cl:generic:: message-trailers .. code-block:: common-lisp-repl GIT> (message-trailers (get-object 'commit "ea010dee347e50666331b77edcf0588735c3205a" (open-repository #p"/home/russell/projects/ecl/"))) '((:key "Fixes" :value "https://example.com/foobar") (:key "Signed-off-by" :value "John Doe ")) .. cl:generic:: author .. code-block:: common-lisp-repl GIT> (author (get-object 'commit "ea010dee347e50666331b77edcf0588735c3205a" (open-repository #p"/home/russell/projects/ecl/"))) (:NAME "jjgarcia" :EMAIL "jjgarcia" :TIME @2001-07-13T02:32:15.000000+10:00 :TIMEZONE #) .. cl:generic:: committer .. code-block:: common-lisp-repl GIT> (committer (get-object 'commit "ea010dee347e50666331b77edcf0588735c3205a" (open-repository #p"/home/russell/projects/ecl/"))) (:NAME "jjgarcia" :EMAIL "jjgarcia" :TIME @2001-07-13T02:32:15.000000+10:00 :TIMEZONE #) .. cl:generic:: parents commit .. code-block:: common-lisp-repl GIT> (parents (get-object 'commit "ea010dee347e50666331b77edcf0588735c3205a" (open-repository #p"/home/russell/projects/ecl/"))) (#) .. cl:generic:: commit-tree To see the state of the repository when this commit was made, use the :cl:symbol:`COMMIT-TREE`. .. code-block:: common-lisp-repl GIT> (commit-tree (target (repository-head (open-repository (merge-pathnames #p"projects/ecl" (user-homedir-pathname)))))) # Graph Traversal --------------- .. versionmodified:: This API is only implemented in libgit2 version 1.2 and greater .. cl:generic:: reachable-from .. code-block:: common-lisp-repl GIT> (with-repository (repository (merge-pathnames #p"projects/cl-git" (user-homedir-pathname))) (reachable-from repository (resolve (car (list-objects 'tag repository)) '(commit)) (list (get-object 'reference "refs/heads/master" repository)))) T