git.fiddlerwoaroof.com
extract.lisp
347e97b1
 (in-package :fwoar.cl-git)
 
6df34ee9
 (defun extract-object-of-type (type s repository pos packfile ref delta-base)
744c84b5
   (with-simple-restart (continue "Skip object of type ~s at position ~d"
                                  type
                                  pos)
4cc1ee49
     (-extract-object-of-type (object-type->sym type)
                              s
                              repository
b27750d1
                              :offset-from pos
744c84b5
                              :packfile packfile
6df34ee9
                              :hash (ref-hash ref)
                              :base delta-base)))
4cc1ee49
 
744c84b5
 (defun extract-loose-object (repo file ref)
500325f0
   (with-open-file (s file :element-type '(unsigned-byte 8))
347e97b1
     (alexandria:when-let ((result (chipz:decompress nil (chipz:make-dstate 'chipz:zlib)
                                                     s)))
077088c8
       (destructuring-bind (type rest)
           (partition (char-code #\space) result)
         (extract-object-of-type (object-type->sym (babel:octets-to-string type))
                                 (elt (partition 0 rest)
                                      1)
4cc1ee49
                                 repo
b27750d1
                                 0
744c84b5
                                 nil
6df34ee9
                                 ref
                                 nil)))))
4cc1ee49
 
 (defgeneric extract-object (object)
   (:method ((object loose-ref))
     (extract-loose-object (ref-repo object)
744c84b5
                           (loose-ref-file object)
48aa14a3
                           object)))