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

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

[elpa] externals/vc-got 2d039a2 089/145: fix vc-dir listing on sub-direc


From: ELPA Syncer
Subject: [elpa] externals/vc-got 2d039a2 089/145: fix vc-dir listing on sub-directories
Date: Thu, 9 Sep 2021 15:58:40 -0400 (EDT)

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

    fix vc-dir listing on sub-directories
    
    Refactor vc-got--status so it a) correctly manages files and b)
    returns filenames relative to the directory.
    
    fixes #13
---
 vc-got.el | 55 ++++++++++++++++++++++++++++++-------------------------
 1 file changed, 30 insertions(+), 25 deletions(-)

diff --git a/vc-got.el b/vc-got.el
index 24b3039..a620d48 100755
--- a/vc-got.el
+++ b/vc-got.el
@@ -212,7 +212,7 @@ worktree."
                      (when reverse '("-R"))
                      path)))))
 
-(defun vc-got--status (status-codes dir-or-file &rest files)
+(defun vc-got--status (status-codes dir-or-file files)
   "Return a list of lists '(FILE STATUS STAGE-STATUS).
 DIR-OR-FILE can be either a directory or a file.  If FILES is
 given, return the status of those files, otherwise the status of
@@ -220,30 +220,35 @@ DIR-OR-FILE.  STATUS-CODES is either nil, or a string 
that's
 passed as the -s flag to got status to limit the types of status
 to report (e.g. \"CD\" to report only conflicts and deleted
 files)."
-  (vc-got-with-worktree dir-or-file
-    (with-temp-buffer
-      (let (process-file-side-effects)
-        (when (zerop (vc-got--call "status"
-                                   (when status-codes (list "-s" status-codes))
-                                   (or files dir-or-file)))
-          (goto-char (point-min))
-          (cl-loop until (eobp)
-                   ;; the format of each line is
-                   ;; <status-char> <stage-char> <spc> <filename> \n
-                   collect (let* ((file-status (prog1 
(vc-got--parse-status-char
-                                                       (char-after))
-                                                 (forward-char)))
-                                  (stage-status (prog1 
(vc-got--parse-stage-char
-                                                        (char-after))
-                                                  (forward-char)))
-                                  (filename (progn
-                                              (forward-char)
-                                              (buffer-substring (point)
-                                                                
(line-end-position)))))
-                             (list filename
-                                   (or file-status (and stage-status 'staged))
-                                   stage-status))
-                   do (forward-line)))))))
+  (with-temp-buffer
+    (let* ((default-directory (expand-file-name
+                               (if (file-directory-p dir-or-file)
+                                   dir-or-file
+                                 (file-name-directory dir-or-file))))
+           (root (vc-got-root default-directory))
+           (process-file-side-effects))
+      (when (zerop (vc-got--call "status"
+                                 (when status-codes (list "-s" status-codes))
+                                 (or files dir-or-file)))
+        (goto-char (point-min))
+        (cl-loop until (eobp)
+                 ;; the format of each line is
+                 ;; <status-char> <stage-char> <spc> <filename> \n
+                 collect (let* ((file-status (prog1 (vc-got--parse-status-char
+                                                     (char-after))
+                                               (forward-char)))
+                                (stage-status (prog1 (vc-got--parse-stage-char
+                                                      (char-after))
+                                                (forward-char)))
+                                (filename (progn
+                                            (forward-char)
+                                            (buffer-substring (point)
+                                                              
(line-end-position)))))
+                           (list (file-relative-name (expand-file-name 
filename root)
+                                                     default-directory)
+                                 (or file-status (and stage-status 'staged))
+                                 stage-status))
+                 do (forward-line))))))
 
 (defun vc-got--parse-status-char (c)
   "Parse status char C into a symbol accepted by `vc-state'."



reply via email to

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