On Fri, 2 Feb 2018 10:27:41 +0530 Prathamesh Chavan <pc44800@xxxxxxxxx> 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? > 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. > Both groups can be found in the wild. The author has no data if one group > outweighs the other by large margin, and offending each one seems equally > bad at first. However in the authors imagination it is better to go with > (a) as running from a sub directory sounds like it is carried out > by a human rather than by some automation task. With a human on > the keyboard the feedback loop is short and the changed behavior can be > adapted to quickly unlike some automation that can break silently. Thanks - this is a good analysis. > git-submodule.sh | 1 - > t/t7407-submodule-foreach.sh | 36 ++++++++++++++++++++++++++++++++++-- I think the documentation should be changed too - $path is the name of the submodule directory relative to the current directory?