git submodule foreach: Provide access to submodule name, as '$name'
The argument to 'git submodule foreach' already has access to the variables '$path' (the path to the submodule, relative to the superproject) and '$sha1' (the submodule commit recorded by the superproject). This patch adds another variable -- '$name' -- which contains the name of the submodule, as recorded in the superproject's .gitmodules file. Signed-off-by: Johan Herland <johan@herland.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johan Herland committed
Aug 16, 2009 at 03:10 UTC
1e7f2aad7dd9b0b5ec8bbae2e3015915687e2cd2
2 files changed
+3
-1
Documentation/git-submodule.txt
+2
-1
@@ -131,7 +131,8 @@ summary::
131
132
foreach::
133
Evaluates an arbitrary shell command in each checked out submodule.
134
- The command has access to the variables $path and $sha1:
134
+ The command has access to the variables $name, $path and $sha1:
135
+ $name is the name of the relevant submodule section in .gitmodules,
136
$path is the name of the submodule directory relative to the
137
superproject, and $sha1 is the commit as recorded in the superproject.
138
Any submodules defined in the superproject but not checked out are
git-submodule.sh
+1
@@ -243,6 +243,7 @@ cmd_foreach()
243
if test -e "$path"/.git
244
then
245
say "Entering '$path'"
246
+ name=$(module_name "$path")
247
(cd "$path" && eval "$@") ||
248
die "Stopping at '$path'; script returned non-zero status."
249
fi