branch: elpa/projectile
commit 2cd6d01c8dccf6ce339f4ccd3372acec22bc2cd9
Author: Bozhidar Batsov <[email protected]>
Commit: Bozhidar Batsov <[email protected]>

    Add 30s timeout to projectile-check-vcs-status busy-wait
    
    The unbounded (while (vc-dir-busy) ...) loop could freeze Emacs
    indefinitely if vc-dir hangs (e.g., broken remote repo). This is
    especially dangerous when called for every known project via
    projectile-check-vcs-status-of-known-projects.
---
 projectile.el | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/projectile.el b/projectile.el
index 3a83b97b66..6ddd367a2d 100644
--- a/projectile.el
+++ b/projectile.el
@@ -6138,8 +6138,10 @@ If PROJECT-PATH is a project, check this one instead."
         (project-status nil))
     (save-excursion
       (vc-dir project-path)
-      ;; wait until vc-dir is done
-      (while (vc-dir-busy) (sleep-for 0.1))
+      ;; wait until vc-dir is done (with a 30s timeout to avoid freezing)
+      (let ((deadline (time-add (current-time) 30)))
+        (while (and (vc-dir-busy) (time-less-p (current-time) deadline))
+          (sleep-for 0.1)))
       ;; check for status
       (save-excursion
         (save-match-data

Reply via email to