git-authenticate: 'commit-authorized-keys' properly handles orphan commits.
authorLudovic Courtès <ludo@gnu.org>
Mon, 8 Jun 2020 20:25:59 +0000 (22:25 +0200)
committerLudovic Courtès <ludo@gnu.org>
Mon, 8 Jun 2020 22:34:52 +0000 (00:34 +0200)
Previously it would trigger a wrong-number-of-arguments error for
'lset-intersection'.

* guix/git-authenticate.scm (commit-authorized-keys): Add case for when
'commit-parents' returns the empty list.

guix/git-authenticate.scm

index 00d22ef..c333717 100644 (file)
@@ -184,8 +184,11 @@ to remove '.guix-authorizations' file")
               default-authorizations)
             (throw key error)))))
 
-  (apply lset-intersection bytevector=?
-         (map commit-authorizations (commit-parents commit))))
+  (match (commit-parents commit)
+    (() default-authorizations)
+    (parents
+     (apply lset-intersection bytevector=?
+            (map commit-authorizations parents)))))
 
 (define* (authenticate-commit repository commit keyring
                               #:key (default-authorizations '()))