emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/vc-got 8228942 050/145: fix vc-got-dir-status-files


From: ELPA Syncer
Subject: [elpa] externals/vc-got 8228942 050/145: fix vc-got-dir-status-files
Date: Thu, 9 Sep 2021 15:58:31 -0400 (EDT)

branch: externals/vc-got
commit 82289421895601458f16fa160107b9154be83342
Author: Omar Polo <op@omarpolo.com>
Commit: Omar Polo <op@omarpolo.com>

    fix vc-got-dir-status-files
    
    now it works correctly even when an untracked files gets deleted.
---
 vc-got.el | 40 +++++++++++++++++++++++++---------------
 1 file changed, 25 insertions(+), 15 deletions(-)

diff --git a/vc-got.el b/vc-got.el
index c36a3ac..746bd0b 100755
--- a/vc-got.el
+++ b/vc-got.el
@@ -362,21 +362,31 @@ DIR-OR-FILE."
     (vc-got--parse-status-flag (vc-got--status file))))
 
 (defun vc-got-dir-status-files (dir files update-function)
-  (let ((fs (seq-filter (lambda (file)
-                          (and (not (string= file ".."))
-                               (not (string= file "."))
-                               (not (string= file ".got"))))
-                        (or files
-                            (directory-files dir)))))
-    (cl-loop with result = (mapcar (lambda (x)
-                                     (list (car x) (cdr x) nil))
-                                   (vc-got--parse-status
-                                    (apply #'vc-got--status dir files)))
-             for file in fs
-             do (unless (cadr (assoc file result #'string=))
-                  (cl-pushnew (list file 'up-to-date nil)
-                              result))
-             finally (funcall update-function result nil))))
+  (let* ((fs (seq-filter (lambda (file)
+                           (and (not (string= file ".."))
+                                (not (string= file "."))
+                                (not (string= file ".got"))))
+                         (or files
+                             (directory-files dir))))
+         (stats (vc-got--parse-status (apply #'vc-got--status dir files)))
+         (res))
+    ;; collect deleted and removed files
+    (cl-loop for (file . st) in stats
+             do (when (or (eq st 'missing)
+                          (eq st 'removed))
+                  (push (list file st nil) res)))
+    (cl-loop for file in fs
+             do (let ((s (if (file-directory-p file)
+                             (list file 'unregistered nil)
+                           (if-let (status (cdr (assoc file stats #'string=)))
+                               (list file status nil)
+                             ;; if file doesn't exists, it's a
+                             ;; untracked file that was removed.
+                             (when (file-exists-p file)
+                               (list file 'up-to-date nil))))))
+                  (when s
+                    (push s res)))
+             finally (funcall update-function res nil))))
 
 (defun vc-got-dir-extra-headers (_dir)
   (concat



reply via email to

[Prev in Thread] Current Thread [Next in Thread]