From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Dmitry Gutov Newsgroups: gmane.emacs.bugs Subject: bug#59722: 30.0.50; project-find-regexp searches project-ignored files Date: Mon, 5 Dec 2022 02:43:53 +0200 Message-ID: <0810182a-7808-5c7b-91f9-bc76374c3263@yandex.ru> References: <9de53f42-8f76-3770-b059-d78a5252d31a@yandex.ru> <1f6b991a-d67e-5e38-b77f-038e97218e4e@yandex.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="37410"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.2 To: Rudolf =?UTF-8?Q?Adamkovi=C4=8D?= , 59722@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Dec 05 01:45:33 2022 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 1p1zbw-0009YO-R6 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 05 Dec 2022 01:45:32 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1p1zbV-0002IG-6m; Sun, 04 Dec 2022 19:45:05 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1p1zbT-0002Hm-0i for bug-gnu-emacs@gnu.org; Sun, 04 Dec 2022 19:45:03 -0500 Original-Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1p1zbS-0006OP-M3 for bug-gnu-emacs@gnu.org; Sun, 04 Dec 2022 19:45:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1p1zbS-0005EM-6E for bug-gnu-emacs@gnu.org; Sun, 04 Dec 2022 19:45:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Dmitry Gutov Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 05 Dec 2022 00:45:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 59722 X-GNU-PR-Package: emacs Original-Received: via spool by 59722-submit@debbugs.gnu.org id=B59722.167020104620084 (code B ref 59722); Mon, 05 Dec 2022 00:45:02 +0000 Original-Received: (at 59722) by debbugs.gnu.org; 5 Dec 2022 00:44:06 +0000 Original-Received: from localhost ([127.0.0.1]:60726 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1zaY-0005Ds-7d for submit@debbugs.gnu.org; Sun, 04 Dec 2022 19:44:06 -0500 Original-Received: from mail-wr1-f42.google.com ([209.85.221.42]:45013) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1p1zaU-0005DN-GF for 59722@debbugs.gnu.org; Sun, 04 Dec 2022 19:44:05 -0500 Original-Received: by mail-wr1-f42.google.com with SMTP id u12so15425294wrr.11 for <59722@debbugs.gnu.org>; Sun, 04 Dec 2022 16:44:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=2Nz1XaDVNdsD4EJkhiOuRaSBx/xZ21CzU2S4/IV1678=; b=SstUsvY8Ods9sF+DTP2nYeRsOgbzmM1fcP+gL3tE3a0rW6EaLiYgYl+ZRCJXNIuJs3 H9y/7cwzsZQFj4EogaqlUIB2e3yvEO6o3JJV3azkj4aXuhE5kz20CZoMIB6lkGf96nFA T0lgye7mKdC7bNhxjfwrMptXe6lgsNDPLHrnX0tZB5ZSd+kkiSVP/iVQ4YVEZk7AYxmB 6TcBvSk4M72iE8muBqBsqGNbYRg6QbjoIBWaGIXmM/pUC1aEHuVVlpnF08oyRFL42NbE VpgH834gNZdlron+8sVTdhPCRNs2qVtiv2VPntZXwXS3Y5sIvPj9lnJ9fFUH1WdcGcjg 4P4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:to :content-language:subject:user-agent:mime-version:date:message-id :sender:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=2Nz1XaDVNdsD4EJkhiOuRaSBx/xZ21CzU2S4/IV1678=; b=Fw62/8CjM77if1MFzghoH1vt3rAO0MMPSErQuksHzv1LW5HBa3hjeDMYRvIgv62C9N g8Aoul0S0/2VuTkRERuAUD02jm7t0JpPNl0RWLUMnNIpwhmM0hbeZ6Woj8QDoQgCEHdB Jx2lI1BTrvJq4rgTPwJky16cvltzF+TXTv9Ze7VDn8Al6bKazmWRVHEumlTnGEWeHFaF aWxdhE47oSArGyKufc56KDu/ZcW2+rwwAAMIF8kZCChyPTFcPwAtZg8rLKX0AtB+G8d0 GiVhNEGjybDLLZPP5039abYMpa3G9pB36zDNNFIKavcvjWv4wiLNSlK1ETgTarU7GOur k0OA== X-Gm-Message-State: ANoB5plhaey+xevJ17g08+goeHwtfceYtFEDSqVQlX2GE4pSQBvTYZ3S cj2u9OY2LsCawN3sejkn5qs= X-Google-Smtp-Source: AA0mqf5XC+uYCuSzdzMB25G4Bcbz4jGV+gBcBSQA25HfcAeFPYDUGDOE9jIm4YFAsfz8D91hLzL63A== X-Received: by 2002:adf:f2c2:0:b0:242:244b:3bcb with SMTP id d2-20020adff2c2000000b00242244b3bcbmr16394797wrp.655.1670201036453; Sun, 04 Dec 2022 16:43:56 -0800 (PST) Original-Received: from [192.168.0.6] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id p21-20020a1c5455000000b003b4cba4ef71sm18860857wmi.41.2022.12.04.16.43.54 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 04 Dec 2022 16:43:55 -0800 (PST) Content-Language: en-US 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-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:249978 Archived-At: On 05/12/2022 01:36, Rudolf Adamkovič via Bug reports for GNU Emacs, the Swiss army knife of text editors wrote: >> Can you step through 'project-find-regexp' with edebug? Does the >> return value of 'project-files' (saved to 'files') contain the extra >> entries? > > So, I debugged the problem. Thanks! > FINDING 1: > > The first finding may explain why I see the ignored files in C-x p g. > > For my dir-local ignore pattern > > ((nil . ((project-ignores . ("apps/**/*.scm"))))) project-vc-ignores, you mean. > Emacs ends up calling > > git ls-files -z -c --exclude-standard \ > --no-empty-directory -o -- :(exclude,glob,top)apps/**/*.scm > > which gives a listing that DOES NOT contain (as expected) any '*.scm' > files in the 'apps' directory, such as > > apps/lib-app-core/src/main/assets/app/atrium.scm > apps/lib-app-core/src/main/assets/app/database.scm > ... > > but it still DOES contain "logically empty" parent directories (as not > expected, perhaps) that would have contained the ignored files if not > ignored, such as > > apps/lib-app-core/src/main/assets/app Huh, interesting. Could you try to show a similar command invocation which would make Git output include a "logically empty" directory for the Emacs repo? So that we have a common public project to compare. Or alternatively a project-vc-ignores value which, when put in .dir-locals.el at the top, produces such effect on the return value of (project-files (project-current)). As a counter-example, if I add (project-vc-ignores . ("./doc/emacs/*")) there, 'project-files' does not include 'doc/emacs/' at all. Not files in it, not it separately as a directory. > My interpretation: > > git ls-files does not output just files, as one would expect, but also > directories with no matching files. grep then gets a list of files and > possibly also directories, and searches through it all. That would make sense, if it's indeed what happens. Perhaps it's a bug in our code, or this behavior is specific to certain versions of Git. I currently have Git 2.37.2 installed. > FINDING 2: > > Given the configuration > > (setq project-switch-use-entire-map t > project-switch-commands '((nil "C-x p"))) > > when I type > > C-x p p <...project...> g > > then Emacs uses the global project ignores and not the ones defined in > the directory-local file. However, > > C-x p g > > inside of any project buffer works OK. And that one is probably a regression from 2389158a31b4a. It won't revert cleanly now, unfortunately. Here's a quick patch which should fix project-switch-project (but not any other potential uses of project-vc values outside of the associated directory): diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el index 3f4a5fb04b..c7fb39b0fb 100644 --- a/lisp/progmodes/project.el +++ b/lisp/progmodes/project.el @@ -1770,7 +1770,11 @@ project-switch-project project-switch-commands (project--switch-project-command)))) (let ((project-current-directory-override dir)) - (call-interactively command)))) + (with-temp-buffer + (let ((default-directory dir) + (enable-local-variables :all)) + (hack-dir-local-variables-non-file-buffer)) + (call-interactively command))))) (provide 'project) ;;; project.el ends here It's mostly to help with your debugging, since it breaks the default prompt for 'project-find-regexp' called from 'C-x p p' as well. I'll have to think of the best way to resolve this: revert said commit outright (with updates for the new code), or do it with certain tweaks. > Notes: > > While probably not the root cause, this bug made debugging much harder, > until I realized it exists, so I report this finding as well. Thank you.