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#61817: 30.0.50; Project.el finds incorrect project roots in git worktrees Date: Mon, 27 Feb 2023 13:51:00 +0200 Message-ID: <66ce5a8f-5321-47b2-b605-38a6aea19190@yandex.ru> References: <5dea8e3b-4867-52f8-19fb-9bf5ab167f46@yandex.ru> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="9187"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.7.1 Cc: 61817@debbugs.gnu.org To: Arthur Miller Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Feb 27 12:52:22 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 1pWc3I-0002Ai-W6 for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 27 Feb 2023 12:52:21 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pWc33-0001gQ-Hv; Mon, 27 Feb 2023 06:52: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 1pWc30-0001T5-2T for bug-gnu-emacs@gnu.org; Mon, 27 Feb 2023 06:52: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 1pWc2z-00005s-Nj for bug-gnu-emacs@gnu.org; Mon, 27 Feb 2023 06:52:01 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pWc2z-0003wG-JE for bug-gnu-emacs@gnu.org; Mon, 27 Feb 2023 06:52:01 -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, 27 Feb 2023 11:52: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.167749867415087 (code B ref 61817); Mon, 27 Feb 2023 11:52:01 +0000 Original-Received: (at 61817) by debbugs.gnu.org; 27 Feb 2023 11:51:14 +0000 Original-Received: from localhost ([127.0.0.1]:46271 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pWc2D-0003vG-U6 for submit@debbugs.gnu.org; Mon, 27 Feb 2023 06:51:14 -0500 Original-Received: from mail-wm1-f45.google.com ([209.85.128.45]:40682) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pWc29-0003v0-3V for 61817@debbugs.gnu.org; Mon, 27 Feb 2023 06:51:11 -0500 Original-Received: by mail-wm1-f45.google.com with SMTP id fm20-20020a05600c0c1400b003ead37e6588so6906294wmb.5 for <61817@debbugs.gnu.org>; Mon, 27 Feb 2023 03:51:09 -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:cc:to :content-language:subject:user-agent:mime-version:date:message-id :sender:from:to:cc:subject:date:message-id:reply-to; bh=vzFxR8JDAfLBaiBtIsXYT3Y7NpWiXTykQ/3Xctl1wIc=; b=SxCdQJYHDPSM57P9JxYzc1Cfzwsll4nvQWX7bKOA0lEjDf3Lu0+RcZ3dKGJoPn8dIS Q88jFjqYf61jxLjNtAEDmrK530s8qoGrWl2aj/wOijo51HM2iO8owgs6sB5TlGRaFnJt Hmno8eWNIG5ZU4A+1/8oWzHvjuLGNWpC1rc1T/HMLL5++fvcam6Sn+7QJ5QbJbYyHWbB ILk416U2VvnQv/gPtv7XRm0exFw7F1hdTarzq73k2DB9RJ6RJeHLt32uiwBr7dot51Tm YrjRR7IKsrB8LhpVn3fAioksGhLwA7929Zjh4o/AHVhPMx8XJBKZve6/7QJjF7vppV21 WNlw== 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:cc: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=vzFxR8JDAfLBaiBtIsXYT3Y7NpWiXTykQ/3Xctl1wIc=; b=7n8hb5DCyGrowLjHKY7TCEvg8wUO+sn9jVymlBOvLq567iDI6zjjWsBOTV8SaQvwuw b9dKC3ujkZdBbO6ZMZoIXYcMoz4xMGclZEM12MnyVlaaUqGBTp7uam5G0B+h9v8pCZKR uAsenNcIE0t0e2GCVTjBAHvv3fHMs3MCA1YHuKu3IdUotNGndcJMAPgU2f5icbIY8Hz8 9y7JUHu5QGMfp4ZfEHVahGA/Zh77YSQu7559MQThtvEsMFuuNyJfmGVRGPUfKHOdrWbX VA8G0gVpeDu4HHFc1kt6mxd0UgJf0pg93yShqjl4/vDoUvypD9IzgQE1MPFtRVIRrT1a e9Iw== X-Gm-Message-State: AO0yUKVe98BkIoEGGoWVhCfiBp3GJhxTcUyCRBpGyi1rcIoym6n0dw0P 8yDXOzEOQueH7NF2T9oCRuw= X-Google-Smtp-Source: AK7set/0qgkBVa3TC4YWZoTpxLB9vBqMpHHxTffEksIkPVHSJkfV3PqNwvSCxFvAtS5MKSw51YZBgg== X-Received: by 2002:a05:600c:16c7:b0:3de:e8c5:d826 with SMTP id l7-20020a05600c16c700b003dee8c5d826mr12438581wmn.28.1677498662935; Mon, 27 Feb 2023 03:51:02 -0800 (PST) Original-Received: from [192.168.0.2] ([46.251.119.176]) by smtp.googlemail.com with ESMTPSA id b10-20020adfee8a000000b002c54c8e70b1sm7173560wro.9.2023.02.27.03.51.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 27 Feb 2023 03:51:02 -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:256873 Archived-At: 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? >>> 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. 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.