GNU bug report logs - #50240
28.0.50; incorrect handling of ignore files in project-files

Previous Next

Package: emacs;

Reported by: Omar Polo <op <at> omarpolo.com>

Date: Sat, 28 Aug 2021 16:53:02 UTC

Severity: normal

Found in version 28.0.50

Fixed in version 28.1

Done: Dmitry Gutov <dgutov <at> yandex.ru>

Bug is archived. No further changes may be made.

Full log


Message #11 received at 50240 <at> debbugs.gnu.org (full text, mbox):

From: Omar Polo <op <at> omarpolo.com>
To: Dmitry Gutov <dgutov <at> yandex.ru>
Cc: 50240 <at> debbugs.gnu.org
Subject: Re: bug#50240: 28.0.50; incorrect handling of ignore files in
 project-files
Date: Sun, 29 Aug 2021 10:30:39 +0200
Dmitry Gutov <dgutov <at> yandex.ru> writes:

> Hi!
>
> On 28.08.2021 19:52, Omar Polo wrote:
>> Hello,
>> I'm working on a custom VC backend and noticed something strange
>> regarding the handling of ignore files in project-files: ignoring a file
>> that has the same name of the project makes project-files return nil.
>> To reproduce:
>> 1. create a directory structure as follows:
>> 	mkdir /tmp/foo
>> 	touch /tmp/foo/{foo,bar}
>> 2. define a trivial project:
>> 	(cl-defmethod project-roots ((_ (eql foo)))
>> 	  '("/tmp/foo/"))
>> 	(cl-defmethod project-ignores ((_ (eql foo)) _)
>> 	  '("foo"))
>> 3. invoke project-files
>> 	(project-files 'foo)
>> 	;; => nil
>
>> This is because project--files-in-directory directory-file-name.
>> The
>> find command build is
>> 	find -H /tmp/foo \( -path \*/foo \) -prune -o  -type f
>> -print0
>> and no files are found because are all pruned.
>
> It might be doing the correct thing, depending on how we define the
> exact semantics of ignores. I guess it will really depend on how this
> is going to be to fix without breaking the previous advancements. ;-)
>
> Try returning "./foo" instead of "foo". Would that work for you? Or
> does your usage require a more general fix?

Yes, with "./foo" the issue is resolved, but I think a more general fix
in project.el is warranted.

It's quite common (at least for C and Go which I use frequently) to
produce a binary in the root directory of the project with the same name
of the project, for example

	/home/op/w/foo/    <- project root
	/home/op/w/foo/foo <- the binary produced

and I expect users to have "foo" in their ignore file, not "./foo", as
they do for e.g. when using git and vc-git.

Also, if one day in the future someone decides to remove the specific
treatment of Git and Hg from project-files this issue will bite
vc-git/hg users too.

I guess I can hack something in my custom vc backend to replace an
ignore entry called "<projectname>" with "./<projectname>", but this
would probably need to be done on every vc backend, excluding git and
hg.

For the time being, I'm using the following patch, but I don't
particularly like it.


diff --git a/project.el b/project.el
index ae9bf03..176947e 100644
--- a/project.el
+++ b/project.el
@@ -302,6 +302,12 @@ to find the list of ignores for each directory."
          ;; expanded and not left for the shell command
          ;; to interpret.
          (localdir (file-name-unquote (file-local-name (expand-file-name dir))))
+         (projectname (file-name-nondirectory (directory-file-name dir)))
+         (ignores (mapcar (lambda (e)
+                            (if (string= projectname e)
+                                (concat "./" e)
+                              e))
+                          ignores))
          (command (format "%s -H %s %s -type f %s -print0"
                           find-program
                           (shell-quote-argument




This bug report was last modified 3 years and 255 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.