{"thread":{"id":"20613","subject":"[PATCH] git submodule foreach: Provide access to submodule name, as '$name'","startedAt":"2009-08-16T01:10:08Z","lastAt":"2009-08-18T00:54:39Z","messageCount":2,"participants":["Johan Herland","Mark Levedahl"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"120754","messageId":"200908160310.08459.johan@herland.net","threadId":"20613","inReplyTo":null,"subject":"[PATCH] git submodule foreach: Provide access to submodule name, as '$name'","fromName":"Johan Herland","fromEmail":"johan@herland.net","sentAt":"2009-08-16T01:10:08Z","receivedAt":"2009-08-16T01:10:08Z","isPatch":true,"sender":{"key":"johan@herland.net","avatar":"https://avatars.githubusercontent.com/u/547031?v=4"},"body":"The argument to 'git submodule foreach' already has access to the variables\n'$path' (the path to the submodule, relative to the superproject) and '$sha1'\n(the submodule commit recorded by the superproject).\n\nThis patch adds another variable -- '$name' -- which contains the name of the\nsubmodule, as recorded in the superproject's .gitmodules file.\n\nSigned-off-by: Johan Herland <johan@herland.net>\n---\n Documentation/git-submodule.txt |    3 ++-\n git-submodule.sh                |    1 +\n 2 files changed, 3 insertions(+), 1 deletions(-)\n\ndiff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt\nindex 7dd73ae..97c32fe 100644\n--- a/Documentation/git-submodule.txt\n+++ b/Documentation/git-submodule.txt\n@@ -131,7 +131,8 @@ summary::\n \n foreach::\n \tEvaluates an arbitrary shell command in each checked out submodule.\n-\tThe command has access to the variables $path and $sha1:\n+\tThe command has access to the variables $name, $path and $sha1:\n+\t$name is the name of the relevant submodule section in .gitmodules,\n \t$path is the name of the submodule directory relative to the\n \tsuperproject, and $sha1 is the commit as recorded in the superproject.\n \tAny submodules defined in the superproject but not checked out are\ndiff --git a/git-submodule.sh b/git-submodule.sh\nindex ebed711..d8ecdb9 100755\n--- a/git-submodule.sh\n+++ b/git-submodule.sh\n@@ -243,6 +243,7 @@ cmd_foreach()\n \t\tif test -e \"$path\"/.git\n \t\tthen\n \t\t\tsay \"Entering '$path'\"\n+\t\t\tname=$(module_name \"$path\")\n \t\t\t(cd \"$path\" && eval \"$@\") ||\n \t\t\tdie \"Stopping at '$path'; script returned non-zero status.\"\n \t\tfi\n-- \n1.6.4.rc3.138.ga6b98.dirty\n"},{"id":"121039","messageId":"4A89FBCF.1080400@gmail.com","threadId":"20613","inReplyTo":"200908160310.08459.johan@herland.net","subject":"Re: [PATCH] git submodule foreach: Provide access to submodule name, as '$name'","fromName":"Mark Levedahl","fromEmail":"mlevedahl@gmail.com","sentAt":"2009-08-18T00:54:39Z","receivedAt":"2009-08-18T00:54:39Z","isPatch":true,"sender":{"key":"mdl123@verizon.net","avatar":"https://avatars.githubusercontent.com/u/5302462?v=4"},"body":"Johan Herland wrote:\n> The argument to 'git submodule foreach' already has access to the variables\n> '$path' (the path to the submodule, relative to the superproject) and '$sha1'\n> (the submodule commit recorded by the superproject).\n>\n> This patch adds another variable -- '$name' -- which contains the name of the\n> submodule, as recorded in the superproject's .gitmodules file.\n>\n> Signed-off-by: Johan Herland <johan@herland.net>\n> ---\n>   \nThis patch *looks* ok to me, but I'm out of the office for most of \nAugust so I cannot actually test this code for another couple of weeks.\n\nMark\n"}]}