unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#48698] [PATCH] git-download: Fix 'git-predicate' handling of deleted files.
@ 2021-05-27 14:17 Andrew Whatson
  2021-05-28 10:10 ` bug#48698: " Ludovic Courtès
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Whatson @ 2021-05-27 14:17 UTC (permalink / raw)
  To: 48698; +Cc: Andrew Whatson

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





^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#48698: [PATCH] git-download: Fix 'git-predicate' handling of deleted files.
  2021-05-27 14:17 [bug#48698] [PATCH] git-download: Fix 'git-predicate' handling of deleted files Andrew Whatson
@ 2021-05-28 10:10 ` Ludovic Courtès
  0 siblings, 0 replies; 2+ messages in thread
From: Ludovic Courtès @ 2021-05-28 10:10 UTC (permalink / raw)
  To: Andrew Whatson; +Cc: 48698-done

Hi Andrew,

Andrew Whatson <whatson@gmail.com> 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’.




^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-05-28 10:11 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-27 14:17 [bug#48698] [PATCH] git-download: Fix 'git-predicate' handling of deleted files Andrew Whatson
2021-05-28 10:10 ` bug#48698: " Ludovic Courtès

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).