From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Arthur Miller Newsgroups: gmane.emacs.bugs Subject: bug#61817: 30.0.50; Project.el finds incorrect project roots in git worktrees Date: Mon, 27 Feb 2023 15:15:42 +0100 Message-ID: References: <5dea8e3b-4867-52f8-19fb-9bf5ab167f46@yandex.ru> <66ce5a8f-5321-47b2-b605-38a6aea19190@yandex.ru> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="12008"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: 61817@debbugs.gnu.org To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Feb 27 15:36:51 2023 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 1pWecT-0002qL-Vz for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 27 Feb 2023 15:36:50 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pWeIU-0007QX-NH; Mon, 27 Feb 2023 09:16:11 -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 1pWeIM-00078j-AP for bug-gnu-emacs@gnu.org; Mon, 27 Feb 2023 09:16:02 -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 1pWeIL-00023q-UV for bug-gnu-emacs@gnu.org; Mon, 27 Feb 2023 09:16:02 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pWeIL-0004Lf-Jf for bug-gnu-emacs@gnu.org; Mon, 27 Feb 2023 09:16:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Arthur Miller Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 27 Feb 2023 14:16:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61817 X-GNU-PR-Package: emacs Original-Received: via spool by 61817-submit@debbugs.gnu.org id=B61817.167750735616701 (code B ref 61817); Mon, 27 Feb 2023 14:16:01 +0000 Original-Received: (at 61817) by debbugs.gnu.org; 27 Feb 2023 14:15:56 +0000 Original-Received: from localhost ([127.0.0.1]:46448 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pWeIF-0004LI-DG for submit@debbugs.gnu.org; Mon, 27 Feb 2023 09:15:56 -0500 Original-Received: from mail-am0eur02olkn2100.outbound.protection.outlook.com ([40.92.49.100]:44385 helo=EUR02-AM0-obe.outbound.protection.outlook.com) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pWeIC-00045m-3T for 61817@debbugs.gnu.org; Mon, 27 Feb 2023 09:15:53 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nvsYNnPu7xObDhbj1uiVzirt+sw92UBpq7r9w+lskkrO+MSuFIZcbNDhNiu4z/IaWCesLCmkZDU/REei6DFaL/RuHRIzTSF26tY3vGD11usXd4ElSC0EH3gUS8CJTJ3oKWlyonqpdP6uC59W8oBSCKZgP8eeTmfbD7+EBayyIywKCTaJmWKqGcZ8zcrmvsdFPQ9iZpBEi734AcSHURppuogJydv3pp32R17QdKrL+iAKGk+O4vG2hEJj3I0hMdfF2DJq6vi7ZfW+pbxczPYeF42hlLgrn7VIoTNHMmLnfjNwcp4obTn2W7WTnAFbe3NFbSD29q+KIzvhJY5AMAfv5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=RRs1cibgKL2Z0NGpFqJ0+WibwKnyVKy5uztXSmNXXTw=; b=ieIrFkbKjueuWPaFzZG+Y6I9s9/KK23VVCHGeJQNttNQ0gOfN6pVWuUtBrglmTSinyqvE2XW1JcXC+QacEBAwWd522vRb/QiYIYh5Vhrp8/o6i2vpGBNET9F43DJb4lqOkJ393Ww9mLd0LGZxTeLJRUH3+JWt0ZNS72IyN74aENQxBdM4rJ5ZjawGDRF8n1++s8fOimXWAdTGCtiDhqi2I51AtQjgx+/0W2kqd7NV8Jkw/Axoz1qC3EewbESllFvCIBFYDpGzkv4oJt5LYH3mCL+hZALGvbMx4VV02U2zJSuaFGnY8y1lHLgZFdmwHvwR9g87k6QNfMwwAhCs3Sp5g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=live.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=RRs1cibgKL2Z0NGpFqJ0+WibwKnyVKy5uztXSmNXXTw=; b=T7r2e8rV8pjo+NZa1rsVubAa436GnhepRro2tIhf3hrOrAicpk8O9tDCCeKm+ZXN/hpPpIc62O8DExmcuNq1J5fm3fBpzr/j2DhLAB1DbsDkOAL1mc7ANcUyapUccj6ZWrYmWLOoafGINKkwHr8ByaiD6D8kKNstCg10FVPwAccZ4V4PRL+2lKxbVNzgiwzlYce59AAw5FwjnqfQw6aJpYtSDKcAHxWhTrcLhZ0Fqw+lAlXnSuxDG8EB1XdDFarWBVtGMggNB4Xi8+FQi72yn1QFKHMBSpMVlZD/p1huhsE2iraDNq8hZ0ecLjbWiFGGc4VDurkF+islEVo8evCNzA== Original-Received: from AM9PR09MB4977.eurprd09.prod.outlook.com (2603:10a6:20b:304::20) by AS2PR09MB6295.eurprd09.prod.outlook.com (2603:10a6:20b:579::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.29; Mon, 27 Feb 2023 14:15:45 +0000 Original-Received: from AM9PR09MB4977.eurprd09.prod.outlook.com ([fe80::f2af:9752:58df:ad9]) by AM9PR09MB4977.eurprd09.prod.outlook.com ([fe80::f2af:9752:58df:ad9%6]) with mapi id 15.20.6134.029; Mon, 27 Feb 2023 14:15:44 +0000 In-Reply-To: <66ce5a8f-5321-47b2-b605-38a6aea19190@yandex.ru> (Dmitry Gutov's message of "Mon, 27 Feb 2023 13:51:00 +0200") X-TMN: [eOvDsmbpgvEeaR4MM6220qTxbuXgGIg8] X-ClientProxiedBy: BE1P281CA0083.DEUP281.PROD.OUTLOOK.COM (2603:10a6:b10:78::9) To AM9PR09MB4977.eurprd09.prod.outlook.com (2603:10a6:20b:304::20) X-Microsoft-Original-Message-ID: <877cw3chyp.fsf@live.com> X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM9PR09MB4977:EE_|AS2PR09MB6295:EE_ X-MS-Office365-Filtering-Correlation-Id: 81f3468d-65c9-45cc-af66-08db18cd1c9f X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Nrp+CeCpuNSgItPqaCWeppIDwlGFoVzj57l3bVRGO2jfPuO949FeeigZLup+ky5JjOY+XOEB8HU9/4DDWwzpnDS0RpWQEuiqkpJKaHxarl0/yimuLr37aZfPRohK9sNSo7u4Fo6YFzM+7OpH8utmH6anckSVcfOabq6g2kORGoGHWAVXL59Y0p3PTYvo0STL0X3qGDIuNdwtem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8dw8d3g2cLb3DO+jDrmTjRuPAnQSaWy//3CTTveZHgxv3BnBmdliMfstwqzQYuFU8CBy3cIO1aj0LjeJCo/iiIt+fqtcds7JZzE7ms6YjF07W+z1GaWsM3FvfAR0w9yyfWsRaVe+2ft0oD+FezrRoGGhONmnhcArH02auj5O0Ol9LgJMWWsmPhRNpbdQpTSepvqvaCbiypLl9QYOvOewXbH/HTyfcYfvs1FUhN2ZxNUwR GKOlWhNy7/X4Ec42nPEZ5KEEpOg/thlSCWFaOwdHxv7InLLFBKfBpULx+c9VDx6Oie3J4/f6ISYsBR1Co6i8IqCLccNzh1DR2k X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-64da6.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: 81f3468d-65c9-45cc-af66-08db18cd1c9f X-MS-Exchange-CrossTenant-AuthSource: AM9PR09MB4977.eurprd09.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Feb 2023 14:15:44.8781 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR09MB6295 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:256883 Archived-At: Dmitry Gutov writes: > On 27/02/2023 09:32, Arthur Miller wrote: >> Dmitry Gutov writes: >> >>> On 26/02/2023 18:23, Arthur Miller wrote: >>>> What actions trigger the bug: >>>> Two different, unrelated repositories with emacs source code tree. My tree(s) >>>> looks like this: >>>> ~/repos/emsrc/emacs/ >>>> ~/repos/enacs-tests/emacs/ >>>> Where in both the last "emacs/" is the Emacs source tree from main git >>>> repository. >>>> ~/repos/emsrc/emacs/ is the one I use for my "everyday" Emacs. I build Emacs >>>> now >>>> and then once in a week or few weeks with a script, and I make each build in its >>>> own our-of-source worktree. The other one is one where I used to do some tests. >>>> It shouldn't matter since all worktrees are contained withing parent directory, >>>> which in one case is "emsrc" and in the other case "emacs-tests", but for some >>>> reason project.el sees the wrong one. >>>> 1. create two parent folders each one containing a copy of emacs sources >>>> 1. create out of source worktree for Emacs source under one of those >>>> 2. navigate to the worktree/lisp/progmodes >>>> 3. run M-: (project-known-project-roots) >>>> In my Emacs, I am in my currently installed emacs worktree, where git root is >>>> ~/repos/emsrc/emacs but project.el returns ("~/repos/emacs-tests/emacs/") as a >>>> result >>> >>> What does (project-root (project-current)) return? And which dirs you are >>> testing it in? >> It returns the current worktree folder: >> "/home/arthur/repos/emsrc/no-gtk-with-cairo-and-native-230226-061643/" >> which I guess is what project.el finds as root since it only uses .git as a >> marker, if I understand correctly what you write little further. >> >>>> I am not chasing the bug, but I don't see much code in project.el related >>>> to worktrees. >>> >>> Normally, there shouldn't be any need to handle worktree specially: it contains >>> a file called .git at the top which can serve as a marker just fine. >> Well define "normally" and "just fine" :). Anyway, when I read your reply it >> seems >> like I have wrong expectation from project.el, so the fault is on my side. I >> thought it can deal with git projects in general, but as I understand it then, >> it only works with files in current directory. > > We could change project-try-vc to follow the link to the parent repo, but how is > the rest of it going to work? > > If the project root is the parent repo, which set of files would (project-files > pr) return? And how could that be implemented? I don't know how it works now, so I can't really tell you, but you have called git root "actual git root", so perhaps something that differentiate between directory hierarchy root (worktree), and real git root (project). Perhaps project-vc-root, if you don't already use that name, or something similar? >>>> The only place I see them mentioned is about submodules.I >>>> personally have used this one for quite some time, and it seems to correctly >>>> handle worktrees for me: >>> >>> You code looks like it can return the "actual git root" that can be a directory >>> residing somewhere else than the current directory tree. >> Git worktrees can be placed outside the main repository tree: >> git worktree add ../my-new-shiny-emacs-patch >> as an example. The code will find correct git root both outside, or within the >> repo. > > Exactly. > >> But I think it should be done by actually asking git to list worktrees >> instead. >> >>> Is that what you >>> wanted? >> Yes that is what I wanted? :-). >> For automation purpose I need to find the project root, so I can pull sources >> to >> main, create a clean worktree from main, and switch Emacs to the new worktree >> interactively in one command, like M-x make-new-patch. Emacs asks me for a name >> and create a clean worktree from the main trunk for current project. Actually >> better variant is to ask which branch to patch, but the first one is slightly >> faster and works just fine in many cases. > > It sounds like your code is Git-specific, not project-neutral. Yepp. Question is what project.el then really is, if it can't handle vc specific "projects", if it is only synomim for operations on directory trees? Perhpas it should be called dirtree.el, because that is what it does: it works on directory trees and uses "project markers" to know where to start/stop? I am not trying to by sarcastic or negative. I don't mean it is not useful, we need both, operations that work as projectile/project, on directory trees, but also those that actually understand a possible project structure. To me projectile and now project.el seems more like they are an extension to Dired, not in some negative connotation, but at least conceptually, then really project handling. I am not trying to be negative, I am a bit oversimplistic and exaggerating, becuase I am trying to illustrate the difference how I think about "projects". Version control has become an integral part of all projects, at least in software industry, just as building projects, boilerplate generating projects etc. What I am saying is that project-neutral is OK, we don't want just a different name for Git commands, but any project library nowadays should be able to work with vc systems, build systems etc. At least for software management projects. > But you still could find the worktree root using project.el, and then read the > contents of .git, follow the link and do your automation stuff. Yeah, but it what does it saves me? In Git case it is really synonym to: (git-dir (locate-dominating-file directory ".git")) I can just as well call built-in function instead of requiring project.el. As said I thought project.el was more general to work with projects on a deeper level, sort-of EDE replacement or complement, and I wanted to use it as library, but I understand now it is not.