From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Philipp Newsgroups: gmane.emacs.bugs 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 Message-ID: <92AAB1AE-0D8C-4C2B-99E9-E790F4BE5330@gmail.com> References: <7f9e984c-bea9-f55f-526a-680a9bb3f66b@yandex.ru> <53E1AC7F-1D49-4845-8DF6-4CB24BC15E6A@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.80.0.2.43\)) Content-Type: multipart/mixed; boundary="Apple-Mail=_94A98D3D-5D69-4EC1-9619-60F3F9E44FE7" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="20440"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 48471@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon May 17 22:03:11 2021 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1lijSI-00055Q-Px for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 17 May 2021 22:03:10 +0200 Original-Received: from localhost ([::1]:59178 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lijSH-0000j8-S4 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 17 May 2021 16:03:09 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34850) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lijSA-0000f4-CC for bug-gnu-emacs@gnu.org; Mon, 17 May 2021 16:03:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:42314) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lijSA-0002w1-43 for bug-gnu-emacs@gnu.org; Mon, 17 May 2021 16:03:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1lijSA-0001nT-0q for bug-gnu-emacs@gnu.org; Mon, 17 May 2021 16:03:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Philipp Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 17 May 2021 20:03:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 48471 X-GNU-PR-Package: emacs Original-Received: via spool by 48471-submit@debbugs.gnu.org id=B48471.16212817716890 (code B ref 48471); Mon, 17 May 2021 20:03:01 +0000 Original-Received: (at 48471) by debbugs.gnu.org; 17 May 2021 20:02:51 +0000 Original-Received: from localhost ([127.0.0.1]:53860 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lijRz-0001n4-2R for submit@debbugs.gnu.org; Mon, 17 May 2021 16:02:51 -0400 Original-Received: from mail-wr1-f52.google.com ([209.85.221.52]:34555) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1lijRy-0001mr-1s for 48471@debbugs.gnu.org; Mon, 17 May 2021 16:02:50 -0400 Original-Received: by mail-wr1-f52.google.com with SMTP id r12so7723138wrp.1 for <48471@debbugs.gnu.org>; Mon, 17 May 2021 13:02:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:message-id:mime-version:subject:date:in-reply-to:cc:to :references; bh=DPZ9d8A3KRNjuGthJ7p7Z6zZXXXRPtdsyYSHmenQf0o=; b=aBaZ5NVZBvkLAZ3H25bVHCSU5oiKb9v6JLPC1GSbq9m31FIVJgW1Vif1X1oyi8V6pA QabkOWa7gcXxIU9InUw4fEgixDsNJQUrnE6mGT38XSqDry1Blw0uBiAxqFxUoK1JOJZ6 ZFet6VgXXxxgDNZN73TeeNrGnAEEhG4VJmZ19LTJoak3Af1GUKBxH0BpsqrYvNKYzjat VFplYym4IBeQDJ7bsEqjE3DgFayVRNso03Saoofc0XaqrMO24EEPIv51r+o2QJzf8lYB 9ffjvITFl2XS0gXtnyeO+gTv5yAjBLa/SFnqCMnebZZDZzkkQjtSyk2yJNZGnTfQY2we cVLQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:message-id:mime-version:subject:date :in-reply-to:cc:to:references; bh=DPZ9d8A3KRNjuGthJ7p7Z6zZXXXRPtdsyYSHmenQf0o=; b=gwh7j13x+tWIKtdU3pOIqpX7WvyRtgbVNOBFANIGaMnZezDLzmcBDYgnPeMwOXVxDq Z69dDFVHvj77s2i0Y3fwq4ZcnBe2wmUtMJwbQQoPKHDnxeUJucrdS5BvzkfIoWv09yBK AOtth5IULL0y6vCeGxqcUIHyUDTZjUD2r/4DplrdO7V+rqVOA0jSQgHGszUH2PGTl1A1 MK7XazQfvjnsWE67kXMWx/atjaTlzWisJYM8tk0bUiQnjnmRO3Z6liSRtwCGVOaMa/aE UgttN7m1tNE+VemcMi3PaYoweFjb4+SHQ56phJ0dFeNrcmM+UBX4a132fYk5JxhdQc+6 5hdw== X-Gm-Message-State: AOAM53021zDPQCWjme1BJ3v2Cj6+GJ+HlIqJ9o3g8JRbyVGsBZuoUXR9 EaHhn4LLwam19wFIRMH/kFc= X-Google-Smtp-Source: ABdhPJyQBzYpgYXfBhhh5ANCpAiu9+OGCBrEh70/IxVvvFMIvIuc9/TKc6Gi2FG1v+69bWLsRxO28w== X-Received: by 2002:a5d:52c5:: with SMTP id r5mr1630016wrv.391.1621281764147; Mon, 17 May 2021 13:02:44 -0700 (PDT) Original-Received: from smtpclient.apple ([46.128.198.100]) by smtp.gmail.com with ESMTPSA id a11sm589284wrr.48.2021.05.17.13.02.43 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 May 2021 13:02:43 -0700 (PDT) In-Reply-To: <53E1AC7F-1D49-4845-8DF6-4CB24BC15E6A@gmail.com> X-Mailer: Apple Mail (2.3654.80.0.2.43) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.io gmane.emacs.bugs:206746 Archived-At: --Apple-Mail=_94A98D3D-5D69-4EC1-9619-60F3F9E44FE7 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii > Am 17.05.2021 um 21:37 schrieb Philipp : >=20 >=20 >=20 >> Am 17.05.2021 um 02:23 schrieb Dmitry Gutov : >>=20 >> Hi! >>=20 >> 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. >>=20 >> Could you track down the piece of code that's misbehaving? Maybe with = a little edebug-ing. >>=20 >> I don't have any BSD find at hand, but >>=20 >> (xref--find-ignores-arguments '("./bar") "/tmp/foo/") >>=20 >> returns >>=20 >> "\\( -path /tmp/foo/bar \\) -prune -o " >>=20 >> here. >=20 > 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: >=20 > find /tmp/foo/ \( -path /tmp/foo/bar \) -prune -o -type f -print0 >=20 > And that doesn't work on macOS: >=20 > $ find /tmp/foo/ \( -path /tmp/foo/bar \) -prune -o -type f -print > /tmp/foo//baz > /tmp/foo//bar >=20 > 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: >=20 > $ gfind /tmp/foo/ \( -path /tmp/foo//bar \) -prune -o -type f -print > /tmp/foo/baz > /tmp/foo/bar >=20 > So probably it's better to use the former option. That works with = both both macOS find and GNU find: >=20 > $ 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 >=20 > 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. --Apple-Mail=_94A98D3D-5D69-4EC1-9619-60F3F9E44FE7 Content-Disposition: attachment; filename=0001-Fix-find-invocation-for-macOS-Bug-48471.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="0001-Fix-find-invocation-for-macOS-Bug-48471.patch" Content-Transfer-Encoding: quoted-printable =46rom=2008e862623eb696a7c3df0404784abf34ed0d1ab6=20Mon=20Sep=2017=20= 00:00:00=202001=0AFrom:=20Philipp=20Stephani=20=0ADate:=20= Mon,=2017=20May=202021=2021:59:57=20+0200=0ASubject:=20[PATCH]=20Fix=20= find=20invocation=20for=20macOS=20(Bug#48471).=0A=0A*=20= lisp/progmodes/project.el=20(project--files-in-directory):=20Instead=20= of=0Aappending=20a=20slash=20(which=20doesn't=20work=20well=20with=20= macOS=20find),=20remove=0Atrailing=20slash=20and=20pass=20-H=20instead.=0A= ---=0A=20lisp/progmodes/project.el=20|=205=20++---=0A=201=20file=20= changed,=202=20insertions(+),=203=20deletions(-)=0A=0Adiff=20--git=20= a/lisp/progmodes/project.el=20b/lisp/progmodes/project.el=0Aindex=20= 047f55ed1a..eab60756c8=20100644=0A---=20a/lisp/progmodes/project.el=0A= +++=20b/lisp/progmodes/project.el=0A@@=20-297,11=20+297,10=20@@=20= project--files-in-directory=0A=20=20=20=20=20=20=20=20=20=20;;=20= expanded=20and=20not=20left=20for=20the=20shell=20command=0A=20=20=20=20=20= =20=20=20=20=20;;=20to=20interpret.=0A=20=20=20=20=20=20=20=20=20=20= (localdir=20(file-name-unquote=20(file-local-name=20(expand-file-name=20= dir))))=0A-=20=20=20=20=20=20=20=20=20(command=20(format=20"%s=20%s=20%s=20= -type=20f=20%s=20-print0"=0A+=20=20=20=20=20=20=20=20=20(command=20= (format=20"%s=20-H=20%s=20%s=20-type=20f=20%s=20-print0"=0A=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= find-program=0A=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20(shell-quote-argument=0A-=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20;;=20In=20case=20= DIR=20is=20a=20symlink.=0A-=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20(file-name-as-directory=20localdir))=0A= +=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20(directory-file-name=20localdir))=20;=20Bug#48471=0A=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= (xref--find-ignores-arguments=20ignores=20localdir)=0A=20=20=20=20=20=20=20= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20(if=20files=0A= =20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20=20= =20=20=20=20=20=20(concat=20(shell-quote-argument=20"(")=0A--=20=0A= 2.30.1=20(Apple=20Git-130)=0A=0A= --Apple-Mail=_94A98D3D-5D69-4EC1-9619-60F3F9E44FE7--