emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: project.el: git submodules?


From: Michael Welsh Duggan
Subject: Re: project.el: git submodules?
Date: Thu, 14 May 2020 17:38:19 -0400
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux)

Dmitry Gutov <address@hidden> writes:

> On 14.05.2020 23:13, Dmitry Gutov wrote:
>> On 14.05.2020 23:01, Stefan Monnier wrote:
>>> +                                    (or
>>> +                                     (let ((default-directory parent))
>>> +                                       (vc-root-dir))
>>> +                                     root)))))
>>>
>>> I'm not familiar enough with this code to understand what it does: which
>>> part tests "is it a submodule"?
>> 
>> The removed part.
>> 
>>> Or alternatively, which part compares
>>> the location of the two repositories?
>> 
>> The part quoted above. If the parent directory of the root of the 
>> current Git worktree belongs to a VC worktree (vc-root-dir returns 
>> non-nil), use that worktree's root. Otherwise, use the root of the 
>> current repo.
>
> Ah. After re-reading your initial message, I think I understand it 
> better. But to compare, we'd need to read the contents of both .git 
> files/directories, right?
>
> That, um, sounds more complex than the current solution. And more file 
> reads = worse performance over Tramp, so it's not just implementation 
> difficulty.
>
> Regarding the particulars, I suppose if .git is a file, and it starts with
>
> gitdir: ../../.git/
>
> where the number of "../" is two or more, then the current dir is 
> probably a submodule.

I think you can just look for ^gitdir:.*/\.git/modules/
After all, I believe submodules all end up having their metadata within
.git/modules.

-- 
Michael Welsh Duggan
(address@hidden)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]