Thread (1 message) 1 message, 1 author, 2016-06-15

Re: git emacs mode patch

From: Alexandre Julliard <hidden>
Date: 2016-06-15 22:43:01

Gábor Melis [off-list ref] writes:
quoted hunk
@@ -515,15 +527,21 @@ and returns the process output as a string."
       (setq node (ewoc-next status node)))
     node))
 
-(defun git-parse-ls-files (status default-state &optional skip-existing)
+(defun git-parse-ls-files (status &optional default-state skip-existing)
   "Parse the output of git-ls-files in the current buffer."
   (goto-char (point-min))
   (let (infolist)
     (while (re-search-forward "\\([HMRCK?]\\) \\([^\0]*\\)\0" nil t 1)
-      (let ((state (match-string 1))
-            (name (match-string 2)))
-        (unless (and skip-existing (git-find-status-file status name))
-          (push (git-create-fileinfo (or (git-state-code state) default-state) name) infolist))))
+      (let* ((state (or default-state
+                        (git-state-code (match-string 1))))
+             (name (match-string 2))
+             (node (git-find-status-file status name)))
+        (if skip-existing
+            (unless node
+              (push (git-create-fileinfo state name) infolist))
+          (if node
+              (git-set-files-state (list (ewoc-data node)) state)
+            (push (git-create-fileinfo state name) infolist)))))
You don't want to do a git-find-status-file in all cases, this is
O(n^2) and becomes much too slow on a large project. That's the reason
there's a skip-existing flag, to avoid that cost in the common case.

-- 
Alexandre Julliard
julliard@winehq.org
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help