unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
* A project-files implementation for Git projects
@ 2019-09-06  9:19 Tassilo Horn
  2019-09-06 12:52 ` Stefan Monnier
  0 siblings, 1 reply; 94+ messages in thread
From: Tassilo Horn @ 2019-09-06  9:19 UTC (permalink / raw)
  To: emacs-devel

Hi all,

I'm struggling a bit with the performance of `project-files' for large
projects so I've tried coming up with a faster implementation for Git
projects which uses "git ls-files" instead of "find".

--8<---------------cut here---------------start------------->8---
(cl-defmethod project-files ((project (head vc)) &optional dirs)
  "Implementation of `project-files' for Git projects."
  (cl-mapcan
   (lambda (dir)
     (if-let ((git (and (file-exists-p
                         (expand-file-name ".git/config" dir))
                        (executable-find "git"))))
         (let ((default-directory dir))
           (sort (split-string
                  (shell-command-to-string
                   (concat git " ls-files -z"))
                  "\0" t)
                 #'string<))
       ;; No Git project, so go with the default.
       (cl-call-next-method)))
   (or dirs (project-roots project))))
--8<---------------cut here---------------end--------------->8---

Some benchmarking shows that it's about 8 times faster on my system.
Would something like this be worthwhile to have in project.el?

Some notes:

- Actually, that hasn't to be a cl-defmethod because the project type vc
  doesn't tell if it's a git project and we still need to test each dir
  separately.  So basically the default implementation could do that
  just as well.  Or maybe the project types could be transient or (vc
  . <backend>) where <backend> is some vc-backend?

- It changes the semantics a bit.  The default implementation finds all
  files (minus the ignored) from a project's directory while git
  ls-files just lists the tracked files.

Bye,
Tassilo



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

end of thread, other threads:[~2019-10-05  6:55 UTC | newest]

Thread overview: 94+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-06  9:19 A project-files implementation for Git projects Tassilo Horn
2019-09-06 12:52 ` Stefan Monnier
2019-09-10  6:25   ` Tassilo Horn
2019-09-10 12:56     ` Stefan Monnier
2019-09-10 13:39       ` Tassilo Horn
2019-09-10 13:56         ` Stefan Monnier
2019-09-11 11:00           ` Tassilo Horn
2019-09-11 20:01             ` Tassilo Horn
2019-09-13 20:38               ` Tassilo Horn
2019-09-14  0:29               ` Dmitry Gutov
2019-09-14 16:26                 ` Tassilo Horn
2019-09-15 18:56                   ` Dmitry Gutov
2019-09-16  2:27                     ` Eli Zaretskii
2019-09-16  3:36                       ` Dmitry Gutov
2019-09-16 15:25                         ` Eli Zaretskii
2019-09-17 10:46                           ` Dmitry Gutov
2019-09-17 12:03                             ` Eli Zaretskii
2019-09-17 12:55                               ` Dmitry Gutov
2019-09-17 13:14                                 ` Eli Zaretskii
2019-09-19 15:33                                   ` Dmitry Gutov
2019-09-19 17:29                                     ` Eli Zaretskii
2019-09-20 11:25                                       ` Dmitry Gutov
2019-09-20 12:59                                         ` Eli Zaretskii
2019-09-20 13:28                                           ` Dmitry Gutov
2019-09-20 13:45                                             ` Stefan Monnier
2019-09-20 13:54                                               ` Dmitry Gutov
2019-09-20 14:12                                                 ` Michael Albinus
2019-09-20 14:30                                                   ` Eli Zaretskii
2019-09-20 14:51                                                     ` Dmitry Gutov
2019-09-20 15:04                                                       ` Michael Albinus
2019-09-22  9:23                                                         ` Dmitry Gutov
2019-09-20 14:55                                                     ` Michael Albinus
2019-09-20 15:55                                                       ` Eli Zaretskii
2019-09-20 15:01                                                 ` Stefan Monnier
2019-09-20 15:59                                                   ` Eli Zaretskii
2019-09-20 17:32                                                     ` Stefan Monnier
2019-09-20 17:49                                                       ` Eli Zaretskii
2019-09-20 18:04                                                         ` Stefan Monnier
2019-09-20 14:23                                             ` Eli Zaretskii
2019-09-20 14:48                                               ` Dmitry Gutov
2019-09-16 13:32                     ` Tassilo Horn
2019-09-17 11:06                       ` Dmitry Gutov
2019-09-18 17:15                         ` Tassilo Horn
2019-09-19 16:01                           ` Dmitry Gutov
2019-09-22  8:56                             ` Tassilo Horn
2019-09-22  9:37                               ` Dmitry Gutov
2019-09-23  7:42                                 ` Tassilo Horn
2019-09-23 12:22                                   ` Dmitry Gutov
2019-09-27 16:17                                     ` Tassilo Horn
2019-09-30  0:09                                       ` Dmitry Gutov
2019-09-30  0:25                                         ` Stefan Monnier
2019-09-30  6:50                                           ` Dmitry Gutov
2019-09-30 17:09                                             ` Stefan Monnier
2019-10-01  8:19                                               ` Dmitry Gutov
2019-10-01 12:31                                                 ` Stefan Monnier
2019-10-01 13:10                                                   ` Stefan Monnier
2019-10-01 23:38                                                     ` Dmitry Gutov
2019-10-03  9:25                                                       ` Felician Nemeth
2019-10-03 10:32                                                         ` Dmitry Gutov
2019-10-03 11:15                                                           ` Felician Nemeth
2019-10-03 12:31                                                             ` Dmitry Gutov
2019-10-03 14:39                                                               ` Felician Nemeth
2019-10-03 14:42                                                                 ` Dmitry Gutov
2019-10-03 15:10                                                                   ` Felician Nemeth
2019-10-03 15:15                                                                     ` Dmitry Gutov
2019-10-01  8:11                                         ` Dmitry Gutov
2019-10-03  8:33                                           ` Tassilo Horn
2019-10-03 13:19                                             ` Dmitry Gutov
2019-10-03 17:15                                               ` Tassilo Horn
2019-10-03 22:49                                                 ` Dmitry Gutov
2019-10-04  7:47                                                   ` Tassilo Horn
2019-10-04  7:58                                                     ` Tassilo Horn
2019-10-04 13:16                                                       ` Dmitry Gutov
2019-10-04  8:49                                                     ` Tassilo Horn
2019-10-04 12:57                                                       ` Dmitry Gutov
2019-10-04 13:59                                                         ` Tassilo Horn
2019-10-04 15:24                                                           ` Dmitry Gutov
2019-10-04 12:16                                                     ` Stefan Monnier
2019-10-04 13:08                                                     ` Dmitry Gutov
2019-10-03  7:41                                         ` Tassilo Horn
2019-10-03 12:33                                           ` Dmitry Gutov
2019-10-03 12:51                                             ` Tassilo Horn
2019-10-04  5:52                                             ` Co-authoring and attribution in commit message (was: A project-files implementation for Git projects) Kévin Le Gouguec
2019-10-04  8:33                                               ` Co-authoring and attribution in commit message Dmitry Gutov
2019-10-04 21:36                                                 ` Karl Fogel
2019-10-05  6:55                                                   ` Eli Zaretskii
2019-10-03 23:02                                         ` A project-files implementation for Git projects Dmitry Gutov
2019-09-14  0:33             ` Dmitry Gutov
2019-09-14 16:43               ` Tassilo Horn
2019-09-15  8:29                 ` Dmitry Gutov
2019-09-15  9:06                   ` Dmitry Gutov
2019-09-10 13:57         ` Robert Pluim
2019-09-10 14:24         ` Dmitry Gutov
2019-09-10 14:41     ` Eli Zaretskii

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

	https://git.savannah.gnu.org/cgit/emacs.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).