Skip to content

Commit

Permalink
git submodule foreach: Provide access to submodule name, as '$name'
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
jherland authored and gitster committed Aug 18, 2009
1 parent 64d5fe0 commit 1e7f2aa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
3 changes: 2 additions & 1 deletion Documentation/git-submodule.txt
Expand Up @@ -131,7 +131,8 @@ summary::

foreach::
Evaluates an arbitrary shell command in each checked out submodule.
The command has access to the variables $path and $sha1:
The command has access to the variables $name, $path and $sha1:
$name is the name of the relevant submodule section in .gitmodules,
$path is the name of the submodule directory relative to the
superproject, and $sha1 is the commit as recorded in the superproject.
Any submodules defined in the superproject but not checked out are
Expand Down
1 change: 1 addition & 0 deletions git-submodule.sh
Expand Up @@ -243,6 +243,7 @@ cmd_foreach()
if test -e "$path"/.git
then
say "Entering '$path'"
name=$(module_name "$path")
(cd "$path" && eval "$@") ||
die "Stopping at '$path'; script returned non-zero status."
fi
Expand Down

0 comments on commit 1e7f2aa

Please sign in to comment.