git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] git-submodule - Add 'foreach' subcommand

From
Petr Baudis <pasky@suse.cz>
Date
Aug 11, 2008, 10:23 UTC
Message-ID
<20080811102344.GG32184@machine.or.cz>
In-Reply-To
<1218409804-1556-1-git-send-email-mlevedahl@gmail.com>
  Hi,
On Sun, Aug 10, 2008 at 07:10:04PM -0400, Mark Levedahl wrote:
Show 7 quoted lines
> submodule foreach <command-list> will execute the list of commands in
> each currently checked out submodule directory. The list of commands
> is arbitrary as long as it is acceptable to sh. The variables '$path'
> and '$sha1' are availble to the command-list, defining the submodule
> path relative to the superproject and the submodules's commitID as
> recorded in the superproject (this may be different than HEAD in the
> submodule).
  in principle, this looks pretty sensible.
Show 12 quoted lines
> diff --git a/Documentation/git-submodule.txt b/Documentation/git-submodule.txt
> index bf33b0c..1e7d352 100644
> --- a/Documentation/git-submodule.txt
> +++ b/Documentation/git-submodule.txt
> @@ -14,6 +14,7 @@ SYNOPSIS
>  'git submodule' [--quiet] init [--] [<path>...]
>  'git submodule' [--quiet] update [--init] [--] [<path>...]
>  'git submodule' [--quiet] summary [--summary-limit <n>] [commit] [--] [<path>...]
> +'git submodule' foreach <command-list>
>  
>  
>  DESCRIPTION
  But as visible here, this is a little bit inconsistent. I think
foreach should be by default verbose about which submodules does it
recurse into - this is what you want in case of casual usage on
command-line. In case you want to have full control on the output within
a script, you can always pass the extra --quiet and it's less obnoxious
this way around.
  I also have a problem with the <command-list> - is this one argument?
Multiple arguments? The semantics is ill-defined. If it is supposed to
be a single argument, please drop the -list bit; silent DWIMmery of
using "$@" internally is acceptable, I guess. If it is supposed to be
multiple arguments, you need to
	(i) Specify that as <command>... instead
	(ii) Either have an eternal annoyance about insane behaviour
here, or use something better than eval "$@". Since
	git submodule foreach cp x\ y z
will simply _not_ work properly.
  So I think it's best to just drop the 'list' part. You're just
evaluating a shell expression passed in a parameter.
Show 6 quoted lines
> @@ -123,6 +124,20 @@ summary::
>  	in the submodule between the given super project commit and the
>  	index or working tree (switched by --cached) are shown.
>  
> +foreach::
> +	Executes an arbitrary list of commands in each checked out submodule.
I think "evaluates" is a better word here, too.
-- 
				Petr "Pasky" Baudis
The next generation of interesting software will be done
on the Macintosh, not the IBM PC.  -- Bill Gates
Previous: Matthias KestenholzNext: Junio C Hamano
Message 8 of 10 in “git-submodule - Add 'foreach' subcommand”
  1. git-submodule - Add 'foreach' subcommandMark Levedahl, Aug 10, 2008
  2. Johan HerlandAug 10, 2008
  3. Junio C HamanoAug 10, 2008
  4. git-submodule - Add 'foreach' subcommandMark Levedahl, Aug 10, 2008
  5. Balazs NagyAug 11, 2008
  6. Johannes SchindelinAug 11, 2008
  7. Matthias KestenholzAug 11, 2008
  8. Petr BaudisAug 11, 2008
  9. Junio C HamanoAug 11, 2008
  10. git-submodule foreach - Include output and clarify usage.Mark Levedahl, Aug 12, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.