git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v1 1/5] submodule foreach: correct '$path' in nested submodules from a subdirectory

From
Stefan Beller <sbeller@google.com>
Date
Feb 6, 2018, 23:11 UTC
Message-ID
<CAGZ79kZ-Z7jq7LZQKdyvgk6zUdsGc1dQERTKvGJ2S3=Sb9dFyg@mail.gmail.com>
In-Reply-To
<20180206145406.b759164cead02cd3bb3fdce0@google.com>
On Tue, Feb 6, 2018 at 2:54 PM, Jonathan Tan <jonathantanmy@google.com> wrote:
Show 16 quoted lines
> On Fri,  2 Feb 2018 10:27:41 +0530
> Prathamesh Chavan <pc44800@gmail.com> wrote:
>
>> When running 'git submodule foreach' from a subdirectory of your
>
> Add "--recursive".
>
>> repository, nested submodules get a bogus value for $sm_path:
>
> Maybe call it $path for now, since $sm_path starts to be recommended
> only in patches after this one.
>
>> For a submodule 'sub' that contains a nested submodule 'nested',
>> running 'git -C dir submodule foreach echo $path' would report
>
> Add "from the root of the superproject", maybe?

This command is run from the root, though the "-C dir" should indicate that the git command runs from the subdirectory. Not sure how much slang this is, or if it can be made easier to understand by writing

  cd dir && git submodule foreach --recursive echo $path
but adding the "from root" part sounds like a clarification nevertheless.
Show 19 quoted lines
>> path='../nested' for the nested submodule. The first part '../' is
>> derived from the logic computing the relative path from $pwd to the
>> root of the superproject. The second part is the submodule path inside
>> the submodule. This value is of little use and is hard to document.
>>
>> There are two different possible solutions that have more value:
>> (a) The path value is documented as the path from the toplevel of the
>>     superproject to the mount point of the submodule.
>>     In this case we would want to have path='sub/nested'.
>>
>> (b) As Ramsay noticed the documented value is wrong. For the non-nested
>>     case the path is equal to the relative path from $pwd to the
>>     submodules working directory. When following this model,
>>     the expected value would be path='../sub/nested'.
>
> A third solution is to use "nested" - that is, the name of the submodule
> directory relative to its superproject. (It's currently documented as
> "the name of the submodule directory relative to the superproject".)
> Having said that, (b) is probably better.

Oh, so the nested would just report "nested/" as that is the path from its superproject to its location. The value does not change depending on where the command is invoked, or whether it is an actual nested or direct submodule? The latter part sounds like a slight modification of (a), but the former part sounds like a completely new version (c).

Previous: Jonathan TanNext: Prathamesh Chavan
Message 5 of 9 in “Incremental rewrite of git-submodules”
  1. 0/5 Incremental rewrite of git-submodulesPrathamesh Chavan, Feb 2, 2018
  2. 1/5 submodule foreach: correct '$path' in nested submodules from a subdirectoryPrathamesh Chavan, Feb 2, 2018
  3. Jonathan TanFeb 6, 2018
  4. Jonathan TanFeb 6, 2018
  5. Stefan BellerFeb 6, 2018
  6. 2/5 submodule foreach: document '$sm_path' instead of '$path'Prathamesh Chavan, Feb 2, 2018
  7. 3/5 submodule foreach: clarify the '$toplevel' variable documentationPrathamesh Chavan, Feb 2, 2018
  8. 4/5 submodule foreach: document variable '$displaypath'Prathamesh Chavan, Feb 2, 2018
  9. 5/5 submodule: port submodule subcommand 'foreach' from shell to CPrathamesh Chavan, Feb 2, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.