all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: "Rudolf Adamkovič" <salutis@me.com>, 59722@debbugs.gnu.org
Subject: bug#59722: 30.0.50; project-find-regexp searches project-ignored files
Date: Mon, 5 Dec 2022 02:43:53 +0200	[thread overview]
Message-ID: <0810182a-7808-5c7b-91f9-bc76374c3263@yandex.ru> (raw)
In-Reply-To: <m24juawxkt.fsf@me.com>

On 05/12/2022 01:36, Rudolf Adamkovič via Bug reports for GNU Emacs, the 
Swiss army knife of text editors wrote:

>> Can you step through 'project-find-regexp' with edebug? Does the
>> return value of 'project-files' (saved to 'files') contain the extra
>> entries?
> 
> So, I debugged the problem.

Thanks!

> FINDING 1:
> 
> The first finding may explain why I see the ignored files in C-x p g.
> 
> For my dir-local ignore pattern
> 
>    ((nil . ((project-ignores . ("apps/**/*.scm")))))

project-vc-ignores, you mean.

> Emacs ends up calling
> 
>    git ls-files -z -c --exclude-standard \
>      --no-empty-directory -o -- :(exclude,glob,top)apps/**/*.scm
> 
> which gives a listing that DOES NOT contain (as expected) any '*.scm'
> files in the 'apps' directory, such as
> 
>    apps/lib-app-core/src/main/assets/app/atrium.scm
>    apps/lib-app-core/src/main/assets/app/database.scm
>    ...
> 
> but it still DOES contain "logically empty" parent directories (as not
> expected, perhaps) that would have contained the ignored files if not
> ignored, such as
> 
>    apps/lib-app-core/src/main/assets/app

Huh, interesting. Could you try to show a similar command invocation 
which would make Git output include a "logically empty" directory for 
the Emacs repo? So that we have a common public project to compare.

Or alternatively a project-vc-ignores value which, when put in 
.dir-locals.el at the top, produces such effect on the return value of 
(project-files (project-current)).

As a counter-example, if I add

   (project-vc-ignores . ("./doc/emacs/*"))

there, 'project-files' does not include 'doc/emacs/' at all. Not files 
in it, not it separately as a directory.

> My interpretation:
> 
> git ls-files does not output just files, as one would expect, but also
> directories with no matching files.  grep then gets a list of files and
> possibly also directories, and searches through it all.

That would make sense, if it's indeed what happens. Perhaps it's a bug 
in our code, or this behavior is specific to certain versions of Git.

I currently have Git 2.37.2 installed.

> FINDING 2:
> 
> Given the configuration
> 
>    (setq project-switch-use-entire-map t
>          project-switch-commands '((nil "C-x p")))
> 
> when I type
> 
>    C-x p p <...project...> g
> 
> then Emacs uses the global project ignores and not the ones defined in
> the directory-local file.  However,
> 
>    C-x p g
> 
> inside of any project buffer works OK.

And that one is probably a regression from 2389158a31b4a.

It won't revert cleanly now, unfortunately. Here's a quick patch which 
should fix project-switch-project (but not any other potential uses of 
project-vc values outside of the associated directory):

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 3f4a5fb04b..c7fb39b0fb 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1770,7 +1770,11 @@ project-switch-project
                       project-switch-commands
                     (project--switch-project-command))))
      (let ((project-current-directory-override dir))
-      (call-interactively command))))
+      (with-temp-buffer
+        (let ((default-directory dir)
+              (enable-local-variables :all))
+          (hack-dir-local-variables-non-file-buffer))
+        (call-interactively command)))))

  (provide 'project)
  ;;; project.el ends here

It's mostly to help with your debugging, since it breaks the default 
prompt for 'project-find-regexp' called from 'C-x p p' as well.

I'll have to think of the best way to resolve this: revert said commit 
outright (with updates for the new code), or do it with certain tweaks.

> Notes:
> 
> While probably not the root cause, this bug made debugging much harder,
> until I realized it exists, so I report this finding as well.

Thank you.





  reply	other threads:[~2022-12-05  0:43 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-30 14:35 bug#59722: 30.0.50; project-find-regexp searches project-ignored files Rudolf Adamkovič via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-30 15:09 ` Dmitry Gutov
2022-11-30 23:20   ` Rudolf Adamkovič via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-11-30 23:30     ` Dmitry Gutov
2022-12-04 23:36       ` Rudolf Adamkovič via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-05  0:43         ` Dmitry Gutov [this message]
2022-12-09 16:21           ` Dmitry Gutov
2022-12-11 12:38           ` Rudolf Adamkovič via Bug reports for GNU Emacs, the Swiss army knife of text editors
2022-12-11 20:13             ` Dmitry Gutov

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=0810182a-7808-5c7b-91f9-bc76374c3263@yandex.ru \
    --to=dgutov@yandex.ru \
    --cc=59722@debbugs.gnu.org \
    --cc=salutis@me.com \
    /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.