* making use of $sm_path @ git submodule foreach —recursive
@ 2022-11-27 22:53 signal
2022-11-28 12:43 ` Ævar Arnfjörð Bjarmason
0 siblings, 1 reply; 3+ messages in thread
From: signal @ 2022-11-27 22:53 UTC (permalink / raw)
To: git
Hi,
when using
git submodule foreach —recursive [..]
$sm_path contains only the relative part of the latest recursion. Since the command has no generic way of knowing from which recursion level it is executed any $sm_path of deeper recursion level is useless unless there is a way for the command to find out from which recursion it is called.
I suggest $sm_path should be extended to be relative to the repo from where the submodule recursion started or another variable should contain the recursive part.
Viele Grüße/Cheers,
Hagen.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: making use of $sm_path @ git submodule foreach —recursive
2022-11-27 22:53 making use of $sm_path @ git submodule foreach —recursive signal
@ 2022-11-28 12:43 ` Ævar Arnfjörð Bjarmason
2022-11-28 14:18 ` signal
0 siblings, 1 reply; 3+ messages in thread
From: Ævar Arnfjörð Bjarmason @ 2022-11-28 12:43 UTC (permalink / raw)
To: signal@dynax.at; +Cc: git
On Sun, Nov 27 2022, signal@dynax.at wrote:
> Hi,
>
> when using
> git submodule foreach —recursive [..]
> $sm_path contains only the relative part of the latest
> recursion. Since the command has no generic way of knowing from which
> recursion level it is executed any $sm_path of deeper recursion level
> is useless unless there is a way for the command to find out from
> which recursion it is called.
>
> I suggest $sm_path should be extended to be relative to the repo from where the submodule recursion started or another variable should contain the recursive part.
>
> Viele Grüße/Cheers,
> Hagen.
I think it might be sensible to have a $super_prefix_sm_path or
something which does what you suggest here.
But the current "$sm_path" is far from useless, it's just not useful for
what you're trying to do.
When we run a command in sub1/sub2 or whatever the "$sm_path" will be
"sub1", then as we cd to "sub1" it'll be "sub2".
You want "sub1/sub2" there, but a "sub2" is still useful, because we've
chdir()'d to the "sub1" at that point.
So you can e.g. run 'git -C "$sm_path" log' in your 'foreach', or
another command that expects to get the *relative* submodule path.
If we simply changed how "$sm_path" works that would break, and if we
"fixed" that by not chdir()-ing from the super-project we'd break even
more things, as e.g.:
git submodule foreach 'git pull'
Or whatever wouldn't behave as you'd expect.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: making use of $sm_path @ git submodule foreach —recursive
2022-11-28 12:43 ` Ævar Arnfjörð Bjarmason
@ 2022-11-28 14:18 ` signal
0 siblings, 0 replies; 3+ messages in thread
From: signal @ 2022-11-28 14:18 UTC (permalink / raw)
To: Ævar Arnfjörð Bjarmason; +Cc: git
Oh, thanks! I didn’t notice that it chdir’ed into the submodule folder! Then clearly this is the relation I was looking for!
Thanks! sorry for the noise!
> On 28.11.2022, at 13:43, Ævar Arnfjörð Bjarmason <avarab@gmail.com> wrote:
>
>
> On Sun, Nov 27 2022, signal@dynax.at wrote:
>
>> Hi,
>>
>> when using
>> git submodule foreach —recursive [..]
>> $sm_path contains only the relative part of the latest
>> recursion. Since the command has no generic way of knowing from which
>> recursion level it is executed any $sm_path of deeper recursion level
>> is useless unless there is a way for the command to find out from
>> which recursion it is called.
>>
>> I suggest $sm_path should be extended to be relative to the repo from where the submodule recursion started or another variable should contain the recursive part.
>>
>> Viele Grüße/Cheers,
>> Hagen.
>
> I think it might be sensible to have a $super_prefix_sm_path or
> something which does what you suggest here.
>
> But the current "$sm_path" is far from useless, it's just not useful for
> what you're trying to do.
>
> When we run a command in sub1/sub2 or whatever the "$sm_path" will be
> "sub1", then as we cd to "sub1" it'll be "sub2".
>
> You want "sub1/sub2" there, but a "sub2" is still useful, because we've
> chdir()'d to the "sub1" at that point.
>
> So you can e.g. run 'git -C "$sm_path" log' in your 'foreach', or
> another command that expects to get the *relative* submodule path.
>
> If we simply changed how "$sm_path" works that would break, and if we
> "fixed" that by not chdir()-ing from the super-project we'd break even
> more things, as e.g.:
>
> git submodule foreach 'git pull'
>
> Or whatever wouldn't behave as you'd expect.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2022-11-28 14:19 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-27 22:53 making use of $sm_path @ git submodule foreach —recursive signal
2022-11-28 12:43 ` Ævar Arnfjörð Bjarmason
2022-11-28 14:18 ` signal
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).