From: Jim Porter <jporterbugs@gmail.com>
To: Eli Zaretskii <eliz@gnu.org>
Cc: dmitry@gutov.dev, 66806@debbugs.gnu.org
Subject: bug#66806: 30.0.50; [PATCH] 'project-find-regexp' passes Git submodules to the search program
Date: Sun, 29 Oct 2023 10:54:28 -0700 [thread overview]
Message-ID: <80277522-c366-2014-8b52-250634090f2e@gmail.com> (raw)
In-Reply-To: <83wmv6arnv.fsf@gnu.org>
[-- Attachment #1: Type: text/plain, Size: 1658 bytes --]
On 10/28/2023 11:06 PM, Eli Zaretskii wrote:
>> Cc: dmitry@gutov.dev
>> Date: Sat, 28 Oct 2023 22:36:07 -0700
>> From: Jim Porter <jporterbugs@gmail.com>
>>
>> --- a/lisp/progmodes/project.el
>> +++ b/lisp/progmodes/project.el
>> @@ -960,7 +960,8 @@ project-find-regexp
>> (default-directory (project-root pr))
>> (files
>> (if (not current-prefix-arg)
>> - (project-files pr)
>> + ;; XXX: See the comment in project-query-replace-regexp.
>> + (cl-delete-if-not #'file-regular-p (project-files pr))
> ^^^^^^^^^^^^^^^^
> I think we want to prefer using seq.el functions, since seq.el is
> nowadays preloaded. Is there a good reason to use cl-delete-if-not
> here?
Well, that's just copy-pasted from some other functions in project.el.
If we want to go the minimal route, I could update all those workarounds.
Or we could go the maximal route and fix it at its source. Here's an
updated patch for the maximal route that uses 'seq-difference'.
Assuming we're ok with the performance characteristics of the maximal
patch, I think the maximal route is best: it fixes the issue at its
source. For performance, it should be faster by default, but a bit
slower when 'project-vc-merge-submodules' is nil (since we need an extra
call to "git" to get the list of submodules). However, that slowness is
compensated for by eliminating the need to call 'file-regular-p' on all
the results for some functions that really do need 'project-files' to
return only files. (If we're really concerned about *exact* perf
numbers, I can try to collect some. Just let me know.)
[-- Attachment #2: maximal_0001-Exclude-Git-submodules-from-project-files.patch --]
[-- Type: text/plain, Size: 2665 bytes --]
From 2a17d5acfcf0b748aaad9d01ff341ed6da315a48 Mon Sep 17 00:00:00 2001
From: Jim Porter <jporterbugs@gmail.com>
Date: Sat, 28 Oct 2023 22:20:41 -0700
Subject: [PATCH] Exclude Git submodules from 'project-files'
* lisp/progmodes/project.el (project--vc-list-files): Exclude Git
submodules.
(project-search, project-query-replace-regexp): Remove now-unneeded
workaround.
---
lisp/progmodes/project.el | 20 +++++++++-----------
1 file changed, 9 insertions(+), 11 deletions(-)
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index fda1081eb62..a3fa1b320a8 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -647,6 +647,7 @@ project--vc-list-files
(include-untracked (project--value-in-dir
'project-vc-include-untracked
dir))
+ (submodules (project--git-submodules))
files)
(setq args (append args
'("-c" "--exclude-standard")
@@ -680,13 +681,14 @@ project--vc-list-files
(setq files
(mapcar
(lambda (file) (concat default-directory file))
- (split-string
- (apply #'vc-git--run-command-string nil "ls-files" args)
- "\0" t)))
+ (seq-difference
+ (split-string
+ (apply #'vc-git--run-command-string nil "ls-files" args)
+ "\0" t)
+ submodules)))
(when (project--vc-merge-submodules-p default-directory)
;; Unfortunately, 'ls-files --recurse-submodules' conflicts with '-o'.
- (let* ((submodules (project--git-submodules))
- (sub-files
+ (let ((sub-files
(mapcar
(lambda (module)
(when (file-directory-p module)
@@ -1326,8 +1328,7 @@ project-search
(interactive "sSearch (regexp): ")
(fileloop-initialize-search
regexp
- ;; XXX: See the comment in project-query-replace-regexp.
- (cl-delete-if-not #'file-regular-p (project-files (project-current t)))
+ (project-files (project-current t))
'default)
(fileloop-continue))
@@ -1348,10 +1349,7 @@ project-query-replace-regexp
(list from to))))
(fileloop-initialize-replace
from to
- ;; XXX: Filter out Git submodules, which are not regular files.
- ;; `project-files' can return those, which is arguably suboptimal,
- ;; but removing them eagerly has performance cost.
- (cl-delete-if-not #'file-regular-p (project-files (project-current t)))
+ (project-files (project-current t))
'default)
(fileloop-continue))
--
2.25.1
next prev parent reply other threads:[~2023-10-29 17:54 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-29 5:36 bug#66806: 30.0.50; [PATCH] 'project-find-regexp' passes Git submodules to the search program Jim Porter
2023-10-29 6:06 ` Eli Zaretskii
2023-10-29 17:54 ` Jim Porter [this message]
2023-10-29 19:22 ` Eli Zaretskii
2023-10-29 22:14 ` Dmitry Gutov
2023-10-29 21:41 ` Dmitry Gutov
2023-10-30 0:58 ` Jim Porter
2023-10-30 2:00 ` Dmitry Gutov
2023-10-30 3:53 ` Jim Porter
2023-10-29 22:02 ` Dmitry Gutov
2023-10-30 0:25 ` Jim Porter
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=80277522-c366-2014-8b52-250634090f2e@gmail.com \
--to=jporterbugs@gmail.com \
--cc=66806@debbugs.gnu.org \
--cc=dmitry@gutov.dev \
--cc=eliz@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.