aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLudovic Courtès <ludo@gnu.org>2021-05-28 11:02:07 +0200
committerLudovic Courtès <ludo@gnu.org>2021-05-28 11:36:02 +0200
commit50d5bb1f3e3f080212436db1b8666d061a8ae1d2 (patch)
tree56d9d8d41ebaffbecbe3a26b1a399b11a0eba159
parent681af1fb78a735b51dc811aed770b2948212c3fc (diff)
downloadguix-50d5bb1f3e3f080212436db1b8666d061a8ae1d2.tar.gz
guix-50d5bb1f3e3f080212436db1b8666d061a8ae1d2.zip
git-download: 'git-predicate' now ignores deleted files.
When git-predicate is used on an active worktree, some files in the index might not exist on the filesystem. Instead of failing with "No such file or directory", these should be ignored. * guix/git-download.scm (git-predicate): Wrap 'lstat' call in 'false-if-exception'. Return RESULT when STAT is #f. Co-authored-by: Andrew Whatson <whatson@gmail.com>
-rw-r--r--guix/git-download.scm12
1 files changed, 7 insertions, 5 deletions
diff --git a/guix/git-download.scm b/guix/git-download.scm
index 199effece5..72084a2249 100644
--- a/guix/git-download.scm
+++ b/guix/git-download.scm
@@ -231,11 +231,13 @@ absolute file name and STAT is the result of 'lstat'."
(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)))
+ (let* ((file (string-append directory "/" file))
+ (stat (false-if-exception (lstat file))))
+ ;; Ignore FILE if it has been deleted.
+ (if stat
+ (vhash-consv (stat:ino stat) (stat:dev stat)
+ result)
+ result)))
vlist-null
files)))
(lambda (file stat)