git.fiddlerwoaroof.com
Browse code

feat: limit depth of rev-list

Ed L authored on 15/11/2020 02:35:15
Showing 1 changed files
... ...
@@ -135,14 +135,19 @@
135 135
 (defun git:commit-parents (commit)
136 136
   (git::parents commit))
137 137
 
138
-(defun git:rev-list (ref-id)
138
+(defun git:rev-list (ref-id &optional (limit nil limit-p))
139 139
   "Return the commits reachable from the ref."
140
-  (labels ((iterate (queue accum)
141
-             (if (null queue)
140
+  (when limit-p
141
+    (rotatef ref-id limit))
142
+  (labels ((iterate (queue accum &optional (count 0))
143
+             (if (or (when limit-p
144
+                       (= limit count))
145
+                     (null queue))
142 146
                  accum
143 147
                  (destructuring-bind (next . rest) queue
144 148
                    (iterate (append rest
145 149
                                     (git::parents next))
146
-                     (cons next accum))))))
150
+                     (cons next accum)
151
+                     (1+ count))))))
147 152
     (iterate (list (ensure-ref ref-id))
148 153
       ())))