From: Jonathan Nieder <jrnieder@gmail.com>
To: Lukasz Palczewski <l.palczewski@prevac.pl>
Cc: git@vger.kernel.org, Johan Herland <johan@herland.net>,
Jens Lehmann <Jens.Lehmann@web.de>
Subject: Re: Restart submodule update --recursive
Date: Fri, 29 Oct 2010 04:12:02 -0500 [thread overview]
Message-ID: <20101029091202.GA26442@burratino> (raw)
In-Reply-To: <loom.20101029T085153-262@post.gmane.org>
Hi Lukasz,
[side note: if you use a newsreader, please reply by mail instead of
through gmane so the Cc: list can be preserved.]
Lukasz Palczewski wrote:
> I think modyfying the git-submodule.sh will be better for me. So I looked into
> it and first problem araised:
> How do I get a name of submodule with a name of a previous submodule?
[...]
> It would be nice if I could get name like this sub1/nsub1 when I am in submodule
> sub1.
What path do you want to get when there are three levels of submodules?
To understand how git-submodule works, it helps to see how low-level it
is. The core is this function:
#
# Get submodule info for registered submodules
# $@ = path to limit submodule list
#
module_list ()
{
git ls-files --error-unmatch --stage -- "$@" | grep '^160000 '
}
which is just reading submodule entries from the index in the current
repository. Like all index entries, they are attached to paths relative to
the toplevel of the current repository.
To get a path relative to the toplevel of the superproject using module_list,
you need to build it up as you go along. For example,
git submodule foreach --recursive 'echo $prefix'
does this (see cmd_foreach).
---
diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt
index 1ed331c..e9bdbca 100644
--- a/Documentation/git-submodule.txt
+++ b/Documentation/git-submodule.txt
@@ -145,17 +145,21 @@ summary::
foreach::
Evaluates an arbitrary shell command in each checked out submodule.
- The command has access to the variables $name, $path, $sha1 and
- $toplevel:
+ The command has access to the variables $name, $path, $prefix, $sha1,
+ and $toplevel:
$name is the name of the relevant submodule section in .gitmodules,
$path is the name of the submodule directory relative to the
superproject, $sha1 is the commit as recorded in the superproject,
- and $toplevel is the absolute path to the top-level of the superproject.
+ $toplevel is the absolute path to the top-level of the superproject,
+ and $toplevel/${prefix}$path is the absolute path for any file
+ in the submodule worktree.
Any submodules defined in the superproject but not checked out are
ignored by this command. Unless given --quiet, foreach prints the name
of each submodule before evaluating the command.
If --recursive is given, submodules are traversed recursively (i.e.
- the given shell command is evaluated in nested submodules as well).
+ the given shell command is evaluated in nested submodules as well)
+ and the superproject used to define $toplevel and $prefix is the
+ outermost project.
A non-zero return from the command in any submodule causes
the processing to terminate. This can be overridden by adding '|| :'
to the end of the command.
--
next prev parent reply other threads:[~2010-10-29 9:12 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-28 7:25 Restart submodule update --recursive Lukasz Palczewski
2010-10-28 10:35 ` Johan Herland
2010-10-29 7:28 ` Lukasz Palczewski
2010-10-28 18:15 ` Jonathan Nieder
2010-10-29 7:17 ` Lukasz Palczewski
2010-10-29 9:12 ` Jonathan Nieder [this message]
2010-10-29 11:37 ` Lukasz Palczewski
2010-10-29 16:40 ` Jonathan Nieder
2010-10-30 7:17 ` Jens Lehmann
2010-11-02 8:18 ` Lukasz Palczewski
2010-11-02 11:08 ` Jens Lehmann
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=20101029091202.GA26442@burratino \
--to=jrnieder@gmail.com \
--cc=Jens.Lehmann@web.de \
--cc=git@vger.kernel.org \
--cc=johan@herland.net \
--cc=l.palczewski@prevac.pl \
/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;
as well as URLs for NNTP newsgroup(s).