Subject: Re: What's cooking in git.git (Oct 2013, #02; Mon, 14)

From: Jonathan Nieder <[email-masked]>
Date: Tue, 15 Oct 2013 12:16:56 -0700

Junio C Hamano wrote:

> I'll try:
>
>  - slurping your integration branches,
>  - teasing the topics apart out of your 'pu',
>  - populating my rerere database to match your confict resolution,
>  - reconstructing the Meta/Reintegrate insn for 'pu', and
>  - rebuilding 'pu' to make sure the end result matches yours
>
> and then push the result out to the usual places

Sounds good.  The teased-apart topics can also be found at

    https://github.com/jrn/git

[...]
>>  This patch preserves the old "just pass it to the shell" behavior
>>  when a single argument is passed to 'git submodule foreach' and
>>  moves to a new "skip the shell and use the arguments passed
>>  unmolested" behavior when more than one argument is passed.
>
> When scripts give 'echo' and '$path' (two args), does this change
> allow the 'echo' command to see the value of $path (coming from
> $sm_path), or just the not-useful-because-not-exported variable name
> '$path'?

The latter.  A quick search (web search + codesearch.debian.net)
reveals that most callers to submodule foreach either pass a script as
a single quoted argument (e.g.,
http://stackoverflow.com/questions/8364738/bash-git-submodule-foreach:

	git submodule foreach '[ "$path" = "Libraries/JSONKit" ] \
	  && branch=experimental \
	  || branch=master; git co $branch'

or http://sources.debian.net/src/jquery/1.7.2+dfsg-3/Makefile?hl=131#L131:

	git submodule foreach "git pull \$(git config remote.origin.url)"

) or pass a one-off command with no arguments intended for the shell
(e.g., http://sources.debian.net/src/libreoffice/1:4.1.1-1/g?hl=352#L352,
http://sources.debian.net/src/swi-prolog/6.4.1-3/scripts/newversion?hl=81#L81):

	git submodule foreach git push "$@"
	git submodule foreach git tag -s -f -F $tmp  $gittag

So I suspect this will fix more scripts than it breaks, though it may
still break some. :/

It might make sense to warn when passed multiple arguments and some
include shell metacharacters, since that's probably rare, too, except
it's punishing people who use multiple arguments as a way to avoid
quoting issues.  Probably there's no replacement for just advertising
the change loudly and seeking out scripts it could break.

Thanks,
Jonathan