summaryrefslogtreecommitdiff
path: root/guix/git-download.scm
diff options
context:
space:
mode:
authorMarius Bakke <mbakke@fastmail.com>2018-09-20 13:37:58 +0200
committerMarius Bakke <mbakke@fastmail.com>2018-09-20 13:37:58 +0200
commit2817ac3c18c1b1a6291c052bc61edd0947890a82 (patch)
tree9985705b35274ae1d6655be789346a98beff63de /guix/git-download.scm
parentecd13016517f0113016fef090782b725fd5e80ce (diff)
parent3e12df7d71547b4eca718b6b0e1fc244722dcc39 (diff)
Merge branch 'master' into core-updates
Diffstat (limited to 'guix/git-download.scm')
-rw-r--r--guix/git-download.scm36
1 files changed, 20 insertions, 16 deletions
diff --git a/guix/git-download.scm b/guix/git-download.scm
index e6e0ec2ac5..24cf11be5e 100644
--- a/guix/git-download.scm
+++ b/guix/git-download.scm
@@ -179,24 +179,28 @@ are relative to DIRECTORY, which is not necessarily the root of the checkout."
(define (git-predicate directory)
"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
absolute file name and STAT is the result of 'lstat'."
- (let* ((files (git-file-list directory))
- (inodes (fold (lambda (file result)
- (let ((stat
- (lstat (string-append directory "/"
- file))))
- (vhash-consv (stat:ino stat) (stat:dev stat)
- result)))
- vlist-null
- files)))
- (lambda (file stat)
- ;; Comparing file names is always tricky business so we rely on inode
- ;; numbers instead.
- (match (vhash-assv (stat:ino stat) inodes)
- ((_ . dev) (= dev (stat:dev stat)))
- (#f #f)))))
+ (catch 'git-error
+ (lambda ()
+ (let* ((files (git-file-list directory))
+ (inodes (fold (lambda (file result)
+ (let ((stat
+ (lstat (string-append directory "/"
+ file))))
+ (vhash-consv (stat:ino stat) (stat:dev stat)
+ result)))
+ vlist-null
+ files)))
+ (lambda (file stat)
+ ;; Comparing file names is always tricky business so we rely on inode
+ ;; numbers instead.
+ (match (vhash-assv (stat:ino stat) inodes)
+ ((_ . dev) (= dev (stat:dev stat)))
+ (#f #f)))))
+ (const #f)))
;;; git-download.scm ends here