Subject: bug#54952: (guix git) crashes with backtrace upon EDQUOT

From: Ludovic Courtès <[email-masked]>
Date: Fri, 15 Apr 2022 14:35:24 +0200

Hello!

The (guix git) code fails badly upon EDQUOT (“Disk quota exceeded”), and
perhaps upon ENOSPC as well:

--8<---------------cut here---------------start------------->8---
$ guix pull
[…]
Backtrace:
           5 (primitive-load "/home/lcirrott/.config/guix/current/bi…")
In guix/ui.scm:
   2206:7  4 (run-guix . _)
  2169:10  3 (run-guix-command _ . _)
In ice-9/boot-9.scm:
  1752:10  2 (with-exception-handler _ _ #:unwind? _ # _)
In guix/git.scm:
    297:2  1 (report-git-error _)
In ice-9/boot-9.scm:
  1685:16  0 (raise-exception _ #:continuable? _)

ice-9/boot-9.scm:1685:16: In procedure raise-exception:
Throw to key `match-error' with args `("match" "no matching pattern" #f)'.
--8<---------------cut here---------------end--------------->8---

Here ‘report-git-error’ gets #f instead of a <git-error>.

Looking at Guile-Git, this happens when ‘giterr_last’ returns NULL:

--8<---------------cut here---------------start------------->8---
(define last-git-error
  (let ((proc (libgit2->procedure '* "giterr_last" '())))
    (lambda (code)
      "Return a <git-error> structure representing the last error, or #f."
      (pointer->git-error (proc) code))))

(define (raise-git-error code)
  "Raise a 'git-error' exception for the given code."
  (throw 'git-error (last-git-error code)))
--8<---------------cut here---------------end--------------->8---

Ludo’.