all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Dmitry Gutov <dgutov@yandex.ru>
To: Omar Polo <op@omarpolo.com>
Cc: 50240@debbugs.gnu.org
Subject: bug#50240: 28.0.50; incorrect handling of ignore files in project-files
Date: Mon, 30 Aug 2021 05:22:40 +0300	[thread overview]
Message-ID: <960e4fe3-4da6-fff6-0bde-799ad4e0265f@yandex.ru> (raw)
In-Reply-To: <87wno48w9d.fsf@omarpolo.com>

On 29.08.2021 11:30, Omar Polo wrote:

> 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.

Fair enough.

> 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.

Unlikely: the special treatment is there foremost for performance. But 
perhaps we'll get a faster universal method for listing files, who knows.

> 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

Please try this patch instead:

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index ae9bf03571..b267185ab0 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -302,10 +302,9 @@ project--files-in-directory
           ;; expanded and not left for the shell command
           ;; to interpret.
           (localdir (file-name-unquote (file-local-name 
(expand-file-name dir))))
-         (command (format "%s -H %s %s -type f %s -print0"
+         (dfn (directory-file-name localdir))
+         (command (format "%s -H . %s -type f %s -print0"
                            find-program
-                          (shell-quote-argument
-                           (directory-file-name localdir)) ; Bug#48471
                            (xref--find-ignores-arguments ignores localdir)
                            (if files
                                (concat (shell-quote-argument "(")
@@ -324,8 +323,9 @@ project--files-in-directory
                         (unless (zerop status)
                           (error "File listing failed: %s" 
(buffer-string))))))))
      (project--remote-file-names
-     (sort (split-string output "\0" t)
-           #'string<))))
+     (mapcar (lambda (s) (concat dfn (substring s 1)))
+             (sort (split-string output "\0" t)
+                   #'string<)))))

  (defun project--remote-file-names (local-files)
    "Return LOCAL-FILES as if they were on the system of 
`default-directory'.






  reply	other threads:[~2021-08-30  2:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-28 16:52 bug#50240: 28.0.50; incorrect handling of ignore files in project-files Omar Polo
2021-08-29  1:17 ` Dmitry Gutov
2021-08-29  8:30   ` Omar Polo
2021-08-30  2:22     ` Dmitry Gutov [this message]
2021-08-30  7:48       ` Omar Polo
2021-09-06  2:06         ` 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=960e4fe3-4da6-fff6-0bde-799ad4e0265f@yandex.ru \
    --to=dgutov@yandex.ru \
    --cc=50240@debbugs.gnu.org \
    --cc=op@omarpolo.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.