diff options
| author | Jim Porter | 2023-10-28 22:20:41 -0700 |
|---|---|---|
| committer | Dmitry Gutov | 2023-10-30 03:42:49 +0200 |
| commit | 271d8b70f8d772807484454d3369f515fdff350a (patch) | |
| tree | fe442f88635271a2b0c112f5ad83f161ee1fcba1 | |
| parent | 1eae0e7edf485bdaa9fb76b905275cf08a1910e2 (diff) | |
| download | emacs-271d8b70f8d772807484454d3369f515fdff350a.tar.gz emacs-271d8b70f8d772807484454d3369f515fdff350a.zip | |
Exclude Git submodules from 'project-files'
* lisp/progmodes/project.el (project--vc-list-files): Exclude Git
submodules (bug#66806).
(project-search, project-query-replace-regexp): Remove now-unneeded
workaround.
| -rw-r--r-- | lisp/progmodes/project.el | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index fda1081eb62..bb44cfefa54 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el | |||
| @@ -647,6 +647,7 @@ See `project-vc-extra-root-markers' for the marker value format.") | |||
| 647 | (include-untracked (project--value-in-dir | 647 | (include-untracked (project--value-in-dir |
| 648 | 'project-vc-include-untracked | 648 | 'project-vc-include-untracked |
| 649 | dir)) | 649 | dir)) |
| 650 | (submodules (project--git-submodules)) | ||
| 650 | files) | 651 | files) |
| 651 | (setq args (append args | 652 | (setq args (append args |
| 652 | '("-c" "--exclude-standard") | 653 | '("-c" "--exclude-standard") |
| @@ -678,23 +679,25 @@ See `project-vc-extra-root-markers' for the marker value format.") | |||
| 678 | i))) | 679 | i))) |
| 679 | extra-ignores))))) | 680 | extra-ignores))))) |
| 680 | (setq files | 681 | (setq files |
| 681 | (mapcar | 682 | (delq nil |
| 682 | (lambda (file) (concat default-directory file)) | 683 | (mapcar |
| 683 | (split-string | 684 | (lambda (file) |
| 684 | (apply #'vc-git--run-command-string nil "ls-files" args) | 685 | (unless (member file submodules) |
| 685 | "\0" t))) | 686 | (concat default-directory file))) |
| 687 | (split-string | ||
| 688 | (apply #'vc-git--run-command-string nil "ls-files" args) | ||
| 689 | "\0" t)))) | ||
| 686 | (when (project--vc-merge-submodules-p default-directory) | 690 | (when (project--vc-merge-submodules-p default-directory) |
| 687 | ;; Unfortunately, 'ls-files --recurse-submodules' conflicts with '-o'. | 691 | ;; Unfortunately, 'ls-files --recurse-submodules' conflicts with '-o'. |
| 688 | (let* ((submodules (project--git-submodules)) | 692 | (let ((sub-files |
| 689 | (sub-files | 693 | (mapcar |
| 690 | (mapcar | 694 | (lambda (module) |
| 691 | (lambda (module) | 695 | (when (file-directory-p module) |
| 692 | (when (file-directory-p module) | 696 | (project--vc-list-files |
| 693 | (project--vc-list-files | 697 | (concat default-directory module) |
| 694 | (concat default-directory module) | 698 | backend |
| 695 | backend | 699 | extra-ignores))) |
| 696 | extra-ignores))) | 700 | submodules))) |
| 697 | submodules))) | ||
| 698 | (setq files | 701 | (setq files |
| 699 | (apply #'nconc files sub-files)))) | 702 | (apply #'nconc files sub-files)))) |
| 700 | ;; 'git ls-files' returns duplicate entries for merge conflicts. | 703 | ;; 'git ls-files' returns duplicate entries for merge conflicts. |
| @@ -1326,8 +1329,7 @@ command \\[fileloop-continue]." | |||
| 1326 | (interactive "sSearch (regexp): ") | 1329 | (interactive "sSearch (regexp): ") |
| 1327 | (fileloop-initialize-search | 1330 | (fileloop-initialize-search |
| 1328 | regexp | 1331 | regexp |
| 1329 | ;; XXX: See the comment in project-query-replace-regexp. | 1332 | (project-files (project-current t)) |
| 1330 | (cl-delete-if-not #'file-regular-p (project-files (project-current t))) | ||
| 1331 | 'default) | 1333 | 'default) |
| 1332 | (fileloop-continue)) | 1334 | (fileloop-continue)) |
| 1333 | 1335 | ||
| @@ -1348,10 +1350,7 @@ If you exit the `query-replace', you can later continue the | |||
| 1348 | (list from to)))) | 1350 | (list from to)))) |
| 1349 | (fileloop-initialize-replace | 1351 | (fileloop-initialize-replace |
| 1350 | from to | 1352 | from to |
| 1351 | ;; XXX: Filter out Git submodules, which are not regular files. | 1353 | (project-files (project-current t)) |
| 1352 | ;; `project-files' can return those, which is arguably suboptimal, | ||
| 1353 | ;; but removing them eagerly has performance cost. | ||
| 1354 | (cl-delete-if-not #'file-regular-p (project-files (project-current t))) | ||
| 1355 | 'default) | 1354 | 'default) |
| 1356 | (fileloop-continue)) | 1355 | (fileloop-continue)) |
| 1357 | 1356 | ||