From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Omar Polo Newsgroups: gmane.emacs.bugs Subject: bug#50240: 28.0.50; incorrect handling of ignore files in project-files Date: Sun, 29 Aug 2021 10:30:39 +0200 Message-ID: <87wno48w9d.fsf@omarpolo.com> References: <87r1edpl4f.fsf@omarpolo.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="13793"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: mu4e 1.6.5; emacs 28.0.50 Cc: 50240@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Sun Aug 29 10:57:16 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 1mKGct-0003KH-KQ for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 29 Aug 2021 10:57:15 +0200 Original-Received: from localhost ([::1]:36308 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mKGcr-0004Uq-2b for geb-bug-gnu-emacs@m.gmane-mx.org; Sun, 29 Aug 2021 04:57:13 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:58598) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mKGcf-0004UR-Us for bug-gnu-emacs@gnu.org; Sun, 29 Aug 2021 04:57:01 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:43944) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1mKGcf-0002iy-N9 for bug-gnu-emacs@gnu.org; Sun, 29 Aug 2021 04:57:01 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1mKGcf-0005sa-MM for bug-gnu-emacs@gnu.org; Sun, 29 Aug 2021 04:57:01 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Omar Polo Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Sun, 29 Aug 2021 08:57:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 50240 X-GNU-PR-Package: emacs Original-Received: via spool by 50240-submit@debbugs.gnu.org id=B50240.163022738722551 (code B ref 50240); Sun, 29 Aug 2021 08:57:01 +0000 Original-Received: (at 50240) by debbugs.gnu.org; 29 Aug 2021 08:56:27 +0000 Original-Received: from localhost ([127.0.0.1]:55490 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mKGc7-0005rf-2X for submit@debbugs.gnu.org; Sun, 29 Aug 2021 04:56:27 -0400 Original-Received: from mail.omarpolo.com ([144.91.116.244]:63603) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1mKGc2-0005rP-Ve for 50240@debbugs.gnu.org; Sun, 29 Aug 2021 04:56:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=omarpolo.com; s=20200327; t=1630227375; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=Nb+N55/loyApZdJkhLpJHSy5D2quGV8j1LbrdLHD7Lc=; b=ltw/ko9YwAWVImuwUFn1psL37xzq1DnAHHbmX01YrOOXXPzqv7kQ0unk8lEY6OOJSUM0i4 2HJlk/Msc1yiuqR+oa0oUN1bIcoipyQ1b3vKRqSOb4T9twIm9Zgeice6FBmz3k3ZEQdKuv HGNmGzKfBazM5O4dJOl0qsSyXb4y03I= Original-Received: from localhost (host-79-25-236-96.retail.telecomitalia.it [79.25.236.96]) by mail.omarpolo.com (OpenSMTPD) with ESMTPSA id d684cf78 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Sun, 29 Aug 2021 10:56:15 +0200 (CEST) Original-Received: from venera (localhost [127.0.0.1]) by localhost (OpenSMTPD) with ESMTP id 57155a70; Sun, 29 Aug 2021 10:56:14 +0200 (CEST) In-reply-to: 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:212921 Archived-At: Dmitry Gutov 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 "" with "./", 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