Commits

evhan  committed 35afb5b

Make commit-parent-id return #f when no parent exists

  • Participants
  • Parent commits de84c51

Comments (0)

Files changed (1)

 (: commit-message-encoding (commit -> string))
 (: commit-message-raw (commit -> string))
 (: commit-parent (commit #!optional fixnum -> (or commit false)))
-(: commit-parent-id (commit -> oid))
+(: commit-parent-id (commit -> (or oid false)))
 (: commit-parentcount (commit -> fixnum))
 (: commit-parents (commit -> (list-of commit)))
 (: commit-repository (commit -> repository))
 
 (define commit-tree      (preserve-owner pointer->tree (compose git-commit-tree commit->pointer)))
 (define commit-tree-id   (compose pointer->oid git-oid-cpy git-commit-tree-id commit->pointer))
-(define commit-parent-id (compose pointer->oid git-oid-cpy git-commit-parent-id commit->pointer))
 (define commit-author    (compose pointer->signature git-signature-dup git-commit-author commit->pointer))
 (define commit-committer (compose pointer->signature git-signature-dup git-commit-committer commit->pointer))
 
+(define (commit-parent-id c #!optional (n 0))
+  (and-let* ((*id (git-commit-parent-id (commit->pointer c) n)))
+    (pointer->oid (git-oid-cpy *id))))
+
 (define (commit-parent cmt #!optional (n 0))
   (condition-case
     (pointer->commit