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
JTJonathan Tan <jonathantanmy@google.com>
Date
Feb 6, 2018, 23:00 UTC
Message-ID
<20180206150044.1bffbb573c088d38c8e44bf5@google.com>
In-Reply-To
<20180206145406.b759164cead02cd3bb3fdce0@google.com>

On Tue, 6 Feb 2018 14:54:06 -0800 Jonathan Tan <jonathantanmy@google.com> wrote:

Show 14 quoted lines
> > 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.
[snip]
Show 24 quoted lines
> > +cat >expect <<EOF
> > +Entering '../nested1'
> > +$pwd/clone2-nested1-nested1-$nested1sha1
> > +Entering '../nested1/nested2'
> > +$pwd/clone2/nested1-nested2-nested2-$nested2sha1
> > +Entering '../nested1/nested2/nested3'
> > +$pwd/clone2/nested1/nested2-nested3-nested3-$nested3sha1
> > +Entering '../nested1/nested2/nested3/submodule'
> > +$pwd/clone2/nested1/nested2/nested3-submodule-submodule-$submodulesha1
> > +Entering '../sub1'
> > +$pwd/clone2-foo1-sub1-$sub1sha1
> > +Entering '../sub2'
> > +$pwd/clone2-foo2-sub2-$sub2sha1
> > +Entering '../sub3'
> > +$pwd/clone2-foo3-sub3-$sub3sha1
> > +EOF
> > +
> > +test_expect_success 'test "submodule foreach --recursive" from subdirectory' '
> > +	(
> > +		cd clone2/untracked &&
> > +		git submodule foreach --recursive "echo \$toplevel-\$name-\$sm_path-\$sha1" >../../actual
> > +	) &&
> > +	test_i18ncmp expect actual
> > +'

Wait a minute...this seems like you're using my "third solution". If we were using either (a) or (b), $sm_path would contain slashes in the case of nested submodules, right?

Previous: Jonathan TanNext: Stefan Beller
Message 4 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.