Subject: bug#48698: closed (Re: bug#48698: [PATCH] git-download: Fix 'git-predicate' handling of deleted files.)

From: [email-masked] (GNU bug Tracking System)
Date: Fri, 28 May 2021 10:11:01 +0000

Your bug report

#48698: [PATCH] git-download: Fix 'git-predicate' handling of deleted files.

which was filed against the guix-patches package, has been closed.

The explanation is attached below, along with your original report.
If you require more details, please reply to [email-masked].

-- 
48698: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=48698
GNU Bug Tracking System
Contact [email-masked] with problems

Subject: Re: bug#48698: [PATCH] git-download: Fix 'git-predicate' handling of deleted files.
From: Ludovic Courtès <[email-masked]>
To: Andrew Whatson <[email-masked]>
Cc: [email-masked]
Date: Fri, 28 May 2021 12:10:09 +0200
List-Id: <debbugs-submit.debbugs.gnu.org>

Hi Andrew,

Andrew Whatson <[email-masked]> skribis:

> 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): Skip missing files.

I pushed a slightly different version as
50d5bb1f3e3f080212436db1b8666d061a8ae1d2, mostly avoiding the extra
‘stat’ call induced by ‘file-exists?’.

Thanks,
Ludo’.

Subject: [PATCH] git-download: Fix 'git-predicate' handling of deleted files.
From: Andrew Whatson <[email-masked]>
To: [email-masked]
Cc: Andrew Whatson <[email-masked]>
Date: Fri, 28 May 2021 00:17:59 +1000
List-Id: <debbugs-submit.debbugs.gnu.org>

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): Skip missing files.
---
 guix/git-download.scm | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/guix/git-download.scm b/guix/git-download.scm
index 199effece5..8d8e1c865f 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* ((path (string-append directory "/" file))
+                                    (stat (and (file-exists? path)
+                                               (lstat path))))
+                               (if stat
+                                   (vhash-consv (stat:ino stat)
+                                                (stat:dev stat) result)
+                                   result)))
                            vlist-null
                            files)))
         (lambda (file stat)
-- 
2.31.1