From: Junio C Hamano <gitster@pobox.com>
To: Mark Levedahl <mlevedahl@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH] git-submodule - Add 'foreach' subcommand
Date: Sun, 10 Aug 2008 15:37:55 -0700 [thread overview]
Message-ID: <7vsktczebg.fsf@gitster.siamese.dyndns.org> (raw)
In-Reply-To: 1218386647-2348-1-git-send-email-mlevedahl@gmail.com
Mark Levedahl <mlevedahl@gmail.com> writes:
> This utility is inspired by a number of threads on the mailing list
> looking for ways to better integrate submodules in a tree and work
> with them as a unit.
Thanks for keeping the topic going
> +foreach::
> + Executes an arbitrary list of commands in each checked out submodule.
> + $path is the name of the submodule directory relative to the
> + superproject, and $sha1 is the commit as recorded in the superproject.
> + And submodules defined in the superproject but not checked out are
> + ignored by this command, and an empty command-list provides no output.
> ++
> +As an example, "git submodule foreach 'echo $path `git rev-parse HEAD`' will
> +show the path and currently checked out commit for each submodule.
I think this is a sensible building block to have.
> +cmd_foreach()
> +{
> + git ls-files --stage | grep '^160000 ' |
> + while read mode sha1 stage path
> + do
> + if test -e "$path"/.git
> + then
> + (cd "$path" && eval "$@")
> + fi
> + done
> +}
I suspect we may want to stop the loop upon failure from eval (any user
that wants to run command in all submodules no matter what could add '||:'
to the cmd list), but other than that this is a simple enough and good
addition.
next prev parent reply other threads:[~2008-08-10 22:39 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-10 16:44 [PATCH] git-submodule - Add 'foreach' subcommand Mark Levedahl
2008-08-10 22:22 ` Johan Herland
2008-08-10 22:37 ` Junio C Hamano [this message]
2008-08-10 23:10 ` Mark Levedahl
2008-08-11 6:28 ` Balazs Nagy
2008-08-11 10:08 ` Johannes Schindelin
2008-08-11 10:11 ` Matthias Kestenholz
2008-08-11 10:23 ` Petr Baudis
2008-08-11 20:40 ` Junio C Hamano
2008-08-12 1:45 ` [PATCH] git-submodule foreach - Include output and clarify usage 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=7vsktczebg.fsf@gitster.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--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 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.