git-download: 'git-predicate' returns #f on Git errors.

Fixes a regression introduced in
aed0a59405 whereby 'git-predicate' would
throw to 'git-error instead of returning #f as the docstring says.

* guix/git-download.scm (git-predicate): Return #f upon 'git-error'.
This commit is contained in:
Ludovic Courtès 2018-09-14 11:11:54 +02:00
parent daa6036fda
commit 13512e1b8f
No known key found for this signature in database
GPG key ID: 090B11993D9AEBB5

View file

@ -179,24 +179,28 @@ (define (git-file-list directory)
(define (git-predicate directory) (define (git-predicate directory)
"Return a predicate that returns true if a file is part of the Git checkout "Return a predicate that returns true if a file is part of the Git checkout
living at DIRECTORY. Upon Git failure, return #f instead of a predicate. living at DIRECTORY. If DIRECTORY does not lie within a Git checkout, and
upon Git errors, return #f instead of a predicate.
The returned predicate takes two arguments FILE and STAT where FILE is an The returned predicate takes two arguments FILE and STAT where FILE is an
absolute file name and STAT is the result of 'lstat'." absolute file name and STAT is the result of 'lstat'."
(let* ((files (git-file-list directory)) (catch 'git-error
(inodes (fold (lambda (file result) (lambda ()
(let ((stat (let* ((files (git-file-list directory))
(lstat (string-append directory "/" (inodes (fold (lambda (file result)
file)))) (let ((stat
(vhash-consv (stat:ino stat) (stat:dev stat) (lstat (string-append directory "/"
result))) file))))
vlist-null (vhash-consv (stat:ino stat) (stat:dev stat)
files))) result)))
(lambda (file stat) vlist-null
;; Comparing file names is always tricky business so we rely on inode files)))
;; numbers instead. (lambda (file stat)
(match (vhash-assv (stat:ino stat) inodes) ;; Comparing file names is always tricky business so we rely on inode
((_ . dev) (= dev (stat:dev stat))) ;; numbers instead.
(#f #f))))) (match (vhash-assv (stat:ino stat) inodes)
((_ . dev) (= dev (stat:dev stat)))
(#f #f)))))
(const #f)))
;;; git-download.scm ends here ;;; git-download.scm ends here