unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#69547: 29.2; project root directory is wrong for submodules of worktrees
@ 2024-03-04 15:21 Patrick Bader
  2024-03-15  2:25 ` Dmitry Gutov
  0 siblings, 1 reply; 2+ messages in thread
From: Patrick Bader @ 2024-03-04 15:21 UTC (permalink / raw)
  To: 69547

[-- Attachment #1: Type: text/plain, Size: 612 bytes --]

Hi,

when navigating to a file in a git submodule, the project root stays in 
the parent repository.
If the submodule is part of a git worktree, however, this does not work 
as expected and the project root switches to the directory of the 
submodule itself.

The issue seems to be how project--submodule-p is checking whether the 
current repository is a submodule.
In the worktree case, there is the worktree path between the .git and 
modules directory in the gitfile.
There may also be regular directory names before the .git directory 
apart of "../".

I have attached a patch to fix this.

Best,

Patrick


[-- Attachment #2: 0001-fix-project-submodule-detection-does-not-work-for-wo.patch --]
[-- Type: text/x-patch, Size: 948 bytes --]

From 5fca51b5d5205b6b3c832246ee5f2cba1af697c0 Mon Sep 17 00:00:00 2001
From: Patrick Bader <patrick.bader@thingos.io>
Date: Mon, 4 Mar 2024 16:14:25 +0100
Subject: [PATCH] fix: project submodule detection does not work for worktrees

---
 lisp/progmodes/project.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 9622b1b6768..2eddda0a67c 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -602,7 +602,7 @@ See `project-vc-extra-root-markers' for the marker value format.")
         (goto-char (point-min))
         ;; Kind of a hack to distinguish a submodule from
         ;; other cases of .git files pointing elsewhere.
-        (looking-at "gitdir: [./]+/\\.git/modules/"))
+        (looking-at "gitdir: .+/\\.git/\\(worktrees/.*\\)?modules/"))
       t)
      (t nil))))
 

base-commit: 5b49a38d1b37707bbbc8c069ed20ce7cd18fb2ac
-- 
2.44.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* bug#69547: 29.2; project root directory is wrong for submodules of worktrees
  2024-03-04 15:21 bug#69547: 29.2; project root directory is wrong for submodules of worktrees Patrick Bader
@ 2024-03-15  2:25 ` Dmitry Gutov
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry Gutov @ 2024-03-15  2:25 UTC (permalink / raw)
  To: Patrick Bader, 69547-done

Hi!

On 04/03/2024 17:21, Patrick Bader wrote:
> when navigating to a file in a git submodule, the project root stays in 
> the parent repository.
> If the submodule is part of a git worktree, however, this does not work 
> as expected and the project root switches to the directory of the 
> submodule itself.
> 
> The issue seems to be how project--submodule-p is checking whether the 
> current repository is a submodule.
> In the worktree case, there is the worktree path between the .git and 
> modules directory in the gitfile.
> There may also be regular directory names before the .git directory 
> apart of "../".
> 
> I have attached a patch to fix this.

Thanks! Installed.





^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-03-15  2:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-04 15:21 bug#69547: 29.2; project root directory is wrong for submodules of worktrees Patrick Bader
2024-03-15  2:25 ` Dmitry Gutov

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).