all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Philipp <p.stephani2@gmail.com>
To: Dmitry Gutov <dgutov@yandex.ru>
Cc: 48471@debbugs.gnu.org
Subject: bug#48471: 28.0.50; Incorrect handling of `project-ignores' on macOS (BSD find?) if project root is a directory name
Date: Mon, 17 May 2021 22:02:42 +0200	[thread overview]
Message-ID: <92AAB1AE-0D8C-4C2B-99E9-E790F4BE5330@gmail.com> (raw)
In-Reply-To: <53E1AC7F-1D49-4845-8DF6-4CB24BC15E6A@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1853 bytes --]



> Am 17.05.2021 um 21:37 schrieb Philipp <p.stephani2@gmail.com>:
> 
> 
> 
>> Am 17.05.2021 um 02:23 schrieb Dmitry Gutov <dgutov@yandex.ru>:
>> 
>> Hi!
>> 
>> On 16.05.2021 23:05, Philipp wrote:
>>> To work around this, XRef should probably only pass directory file names
>>> to find, not directory names, at least on macOS.
>> 
>> Could you track down the piece of code that's misbehaving? Maybe with a little edebug-ing.
>> 
>> I don't have any BSD find at hand, but
>> 
>> (xref--find-ignores-arguments '("./bar") "/tmp/foo/")
>> 
>> returns
>> 
>> "\\( -path /tmp/foo/bar \\) -prune -o "
>> 
>> here.
> 
> Yes, and that's the problem.  macOS find compares the "-path" value against /tmp/foo//bar (note the double slash), and that doesn't match.  The exact shell command generated by project--files-in-directory is:
> 
>  find /tmp/foo/ \( -path /tmp/foo/bar \) -prune -o  -type f  -print0
> 
> And that doesn't work on macOS:
> 
> $ find /tmp/foo/ \( -path /tmp/foo/bar \) -prune -o  -type f  -print
> /tmp/foo//baz
> /tmp/foo//bar
> 
> This needs to be either "find /tmp/foo ..." (no trailing slash) or "-path /tmp/foo//bar" (double slash).  However, the latter than fails with GNU find:
> 
> $ gfind /tmp/foo/ \( -path /tmp/foo//bar \) -prune -o  -type f  -print
> /tmp/foo/baz
> /tmp/foo/bar
> 
> So probably it's better to use the former option.  That works with both both macOS find and GNU find:
> 
> $ find /tmp/foo \( -path /tmp/foo/bar \) -prune -o  -type f  -print
> /tmp/foo/baz
> $ gfind /tmp/foo \( -path /tmp/foo/bar \) -prune -o  -type f  -print
> /tmp/foo/baz
> 
> There's a comment in project--files-in-directory ";; In case DIR is a symlink."  Probably the command should use the -H option instead.

The attached patch fixes both unit tests for project.el on my macOS system.

[-- Attachment #2: 0001-Fix-find-invocation-for-macOS-Bug-48471.patch --]
[-- Type: application/octet-stream, Size: 1496 bytes --]

From 08e862623eb696a7c3df0404784abf34ed0d1ab6 Mon Sep 17 00:00:00 2001
From: Philipp Stephani <phst@google.com>
Date: Mon, 17 May 2021 21:59:57 +0200
Subject: [PATCH] Fix find invocation for macOS (Bug#48471).

* lisp/progmodes/project.el (project--files-in-directory): Instead of
appending a slash (which doesn't work well with macOS find), remove
trailing slash and pass -H instead.
---
 lisp/progmodes/project.el | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 047f55ed1a..eab60756c8 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -297,11 +297,10 @@ 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 %s %s -type f %s -print0"
+         (command (format "%s -H %s %s -type f %s -print0"
                           find-program
                           (shell-quote-argument
-                           ;; In case DIR is a symlink.
-                           (file-name-as-directory localdir))
+                           (directory-file-name localdir)) ; Bug#48471
                           (xref--find-ignores-arguments ignores localdir)
                           (if files
                               (concat (shell-quote-argument "(")
-- 
2.30.1 (Apple Git-130)


  reply	other threads:[~2021-05-17 20:02 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-05-16 20:05 bug#48471: 28.0.50; Incorrect handling of `project-ignores' on macOS (BSD find?) if project root is a directory name Philipp
2021-05-17  0:23 ` Dmitry Gutov
2021-05-17 19:37   ` Philipp
2021-05-17 20:02     ` Philipp [this message]
2021-05-17 23:06       ` Dmitry Gutov
2021-05-23 11:08         ` Philipp
2021-05-29 21:44           ` Dmitry Gutov
2021-05-30  4:29             ` Lars Ingebrigtsen
2021-05-30 11:13               ` Dmitry Gutov
2021-05-31  5:33                 ` Lars Ingebrigtsen
2021-05-30  6:31             ` Eli Zaretskii
2021-05-30 11:14               ` Dmitry Gutov
2021-05-30 16:27               ` Paul Eggert
2021-05-30 16:36                 ` Eli Zaretskii
2021-06-07  1:58                   ` Dmitry Gutov
2021-06-07  8:51                     ` Daniel Martín via Bug reports for GNU Emacs, the Swiss army knife of text editors
2021-06-07 18:48                     ` Philipp
     [not found]                 ` <ff528f00-ac80-4a84-fafb-076896793930@yandex.ru>
2021-10-09 22:14                   ` Paul Eggert
     [not found]                   ` <4de8fa95-e8f3-d07f-2f0c-8b06feff7190@cs.ucla.edu>
2021-10-09 22:29                     ` 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=92AAB1AE-0D8C-4C2B-99E9-E790F4BE5330@gmail.com \
    --to=p.stephani2@gmail.com \
    --cc=48471@debbugs.gnu.org \
    --cc=dgutov@yandex.ru \
    /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.