All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] git submodule foreach: Provide access to submodule name, as '$name'
@ 2009-08-16  1:10 Johan Herland
  2009-08-18  0:54 ` Mark Levedahl
  0 siblings, 1 reply; 2+ messages in thread
From: Johan Herland @ 2009-08-16  1:10 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Git Mailing List, Mark Levedahl, Lars Hjemli

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] git submodule foreach: Provide access to submodule name, as '$name'
  2009-08-16  1:10 [PATCH] git submodule foreach: Provide access to submodule name, as '$name' Johan Herland
@ 2009-08-18  0:54 ` Mark Levedahl
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Levedahl @ 2009-08-18  0:54 UTC (permalink / raw)
  To: Johan Herland; +Cc: Junio C Hamano, Git Mailing List, Lars Hjemli

Johan Herland wrote:
> 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>
> ---
>   
This patch *looks* ok to me, but I'm out of the office for most of 
August so I cannot actually test this code for another couple of weeks.

Mark

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-08-18  0:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-08-16  1:10 [PATCH] git submodule foreach: Provide access to submodule name, as '$name' Johan Herland
2009-08-18  0:54 ` Mark Levedahl

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.