git.fiddlerwoaroof.com
Browse code

Implement git:rev-list

Javier Olaechea authored on 14/11/2020 06:40:17
Showing 2 changed files
... ...
@@ -11,4 +11,5 @@
11 11
   (:use)
12 12
   (:export #:show #:branch #:branches #:commit-parents #:in-repository
13 13
            #:with-repository #:current-repository #:show-repository #:git
14
-           #:tree #:contents #:component))
14
+           #:tree #:contents #:component
15
+           #:rev-list))
... ...
@@ -132,3 +132,13 @@
132 132
   (alexandria:mappend 'cdr (component :parents commit)))
133 133
 (defun git:commit-parents (commit)
134 134
   (git::parents commit))
135
+
136
+(defun git:rev-list (ref-id)
137
+  "Return the commits reachable from the ref."
138
+  (labels ((iterate (queue accum)
139
+             (if (null queue)
140
+                 accum
141
+                 (iterate (append (cdr queue)
142
+                                  (git::parents (ensure-ref (car queue))))
143
+                   (cons (car queue) accum)))))
144
+    (iterate (list ref-id) ())))