"git submodule foreach" provides helpful variables $toplevel and $path,
with semantics
- $toplevel is the absolute path to the top-level of the superproject
- $path is the name of the submodule directory relative to the
superproject
When dealing with nested submodules, those refer to the absolute path
of the parent of the current project and the name of the submodule
directory relative to the parent of the current project.
It would be convenient to have similar variables referring to the
absolute path of the toplevel project and the name of the current
submodule directory relative to that toplevel project.
This can be emulated using
top=$(git rev-parse --show-toplevel) \
git submodule foreach --recursive '
cwd=$(pwd)
fullpath=${cwd#$top/}
...
'