diff options
| author | Sean Allred | 2024-09-29 04:00:32 +0300 |
|---|---|---|
| committer | Dmitry Gutov | 2024-09-29 04:02:13 +0300 |
| commit | 8d9a4647fbc6c57e82045ecd2b3f157ece399e9e (patch) | |
| tree | f016370fc2e310a68b7105d58fa381acaecdf3ce | |
| parent | c934450d14dacfef5e846a743d9637ba1ec6f5a3 (diff) | |
| download | emacs-8d9a4647fbc6c57e82045ecd2b3f157ece399e9e.tar.gz emacs-8d9a4647fbc6c57e82045ecd2b3f157ece399e9e.zip | |
project--vc-list-files: Use '--sparse' with 'git ls-files'
When dealing with exceptionally large Git repositories, the
performance of `project-find-file` can suffer dramatically as
the list of files is collected for completion. This adds insult
to injury when you consider cases where the developer has
configured the repository to use a sparse checkout where the
vast majority of these files are not even present on disk and
are not valid candidates for completion.
* lisp/progmodes/project.el (project--vc-list-files):
Pass 'sparse' to 'git ls-files' when Git is recent enough.
Filter out file names that end with '/' (bug#73320).
| -rw-r--r-- | lisp/progmodes/project.el | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index b29d5ed5404..599a350e5ce 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el | |||
| @@ -663,7 +663,7 @@ See `project-vc-extra-root-markers' for the marker value format.") | |||
| 663 | (pcase backend | 663 | (pcase backend |
| 664 | (`Git | 664 | (`Git |
| 665 | (let* ((default-directory (expand-file-name (file-name-as-directory dir))) | 665 | (let* ((default-directory (expand-file-name (file-name-as-directory dir))) |
| 666 | (args '("-z")) | 666 | (args '("-z" "-c" "--exclude-standard")) |
| 667 | (vc-git-use-literal-pathspecs nil) | 667 | (vc-git-use-literal-pathspecs nil) |
| 668 | (include-untracked (project--value-in-dir | 668 | (include-untracked (project--value-in-dir |
| 669 | 'project-vc-include-untracked | 669 | 'project-vc-include-untracked |
| @@ -671,7 +671,8 @@ See `project-vc-extra-root-markers' for the marker value format.") | |||
| 671 | (submodules (project--git-submodules)) | 671 | (submodules (project--git-submodules)) |
| 672 | files) | 672 | files) |
| 673 | (setq args (append args | 673 | (setq args (append args |
| 674 | '("-c" "--exclude-standard") | 674 | (and (version<= "2.35" (vc-git--program-version)) |
| 675 | '("--sparse")) | ||
| 675 | (and include-untracked '("-o")))) | 676 | (and include-untracked '("-o")))) |
| 676 | (when extra-ignores | 677 | (when extra-ignores |
| 677 | (setq args (append args | 678 | (setq args (append args |
| @@ -703,7 +704,10 @@ See `project-vc-extra-root-markers' for the marker value format.") | |||
| 703 | (delq nil | 704 | (delq nil |
| 704 | (mapcar | 705 | (mapcar |
| 705 | (lambda (file) | 706 | (lambda (file) |
| 706 | (unless (member file submodules) | 707 | (unless (or (member file submodules) |
| 708 | ;; Should occur for sparse directories | ||
| 709 | ;; only, when sparse index is enabled. | ||
| 710 | (directory-name-p file)) | ||
| 707 | (if project-files-relative-names | 711 | (if project-files-relative-names |
| 708 | file | 712 | file |
| 709 | (concat default-directory file)))) | 713 | (concat default-directory file)))) |