-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathextract.lisp
More file actions
34 lines (31 loc) · 1.45 KB
/
extract.lisp
File metadata and controls
34 lines (31 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
(in-package :fwoar.cl-git)
(defun extract-object-of-type (type s repository pos packfile ref delta-base)
(with-simple-restart (continue "Skip object of type ~s at position ~d"
type
pos)
(-extract-object-of-type (object-type->sym type)
s
repository
:offset-from pos
:packfile packfile
:hash (ref-hash ref)
:base delta-base)))
(defun extract-loose-object (repo file ref)
(with-open-file (s file :element-type '(unsigned-byte 8))
(alexandria:when-let ((result (chipz:decompress nil (chipz:make-dstate 'chipz:zlib)
s)))
(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)
repo
0
nil
ref
nil)))))
(defgeneric extract-object (object)
(:method ((object loose-ref))
(extract-loose-object (ref-repo object)
(fwoar.cl-git.ref:loose-ref-file object)
object)))