From: Johan Herland <johan@herland.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Git Mailing List <git@vger.kernel.org>,
Mark Levedahl <mlevedahl@gmail.com>,
Lars Hjemli <hjemli@gmail.com>
Subject: [PATCH] git submodule foreach: Provide access to submodule name, as '$name'
Date: Sun, 16 Aug 2009 03:10:08 +0200 [thread overview]
Message-ID: <200908160310.08459.johan@herland.net> (raw)
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>
---
Documentation/git-submodule.txt | 3 ++-
git-submodule.sh | 1 +
2 files changed, 3 insertions(+), 1 deletions(-)
diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt
index 7dd73ae..97c32fe 100644
--- a/Documentation/git-submodule.txt
+++ b/Documentation/git-submodule.txt
@@ -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
diff --git a/git-submodule.sh b/git-submodule.sh
index ebed711..d8ecdb9 100755
--- a/git-submodule.sh
+++ b/git-submodule.sh
@@ -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
--
1.6.4.rc3.138.ga6b98.dirty
next reply other threads:[~2009-08-16 1:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-16 1:10 Johan Herland [this message]
2009-08-18 0:54 ` [PATCH] git submodule foreach: Provide access to submodule name, as '$name' Mark Levedahl
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=200908160310.08459.johan@herland.net \
--to=johan@herland.net \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
--cc=hjemli@gmail.com \
--cc=mlevedahl@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox