git.fiddlerwoaroof.com
repository.lisp
4cc1ee49
 (in-package :fwoar.cl-git)
 
 (defun root-of (repo)
   (typecase repo
     (repository (root repo))
     ((or pathname string) (namestring
                            (truename repo)))))
 
15785ea0
 (defgeneric ref (repo id)
   (:documentation "Given a REPOsitory and a ref ID return the ref-id object.")
   (:method ((repo git-repository) (id string))
     (let ((repo-root (root-of repo)))
       (or (alexandria:when-let ((object-file (loose-object repo id)))
             (make-instance 'loose-ref
4cc1ee49
                            :repo repo-root
15785ea0
                            :hash id
                            :file object-file))
           (multiple-value-bind (pack offset) (find-object-in-pack-files repo-root id)
             (when pack
               (make-instance 'packed-ref
                              :hash id
                              :repo repo-root
                              :offset offset
                              :pack pack)))))))
216c17e7
 
 (defun ensure-ref (thing &optional (repo *git-repository*))
   (typecase thing
     (git-ref thing)
     (t (ref repo thing))))
 
 (defun ensure-repository (thing)
c672c979
   (repository thing))