Dmitry Gutov <dgutov@yandex.ru> 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.
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.