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

Re: [PATCH v4 1/2] for-each-repo: new command used for multi-repo operations

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Jan 28, 2013, 08:10 UTC
Message-ID
<20130128081006.GA2434@elie.Belkin>
In-Reply-To
<CAFXTnz6GTVgY4DK-FLELGF-Cb1=iNYyWcUsUiaUytGRx9Tr4Ow@mail.gmail.com>
Hi,
Lars Hjemli wrote:
Show 5 quoted lines
> [1] The 'git -a' rewrite patch shows how I think about this command -
> it's just an option to the 'git' command, modifying the way any
> subcommand is invoked (btw: I don't expect that patch to be applied
> since 'git-all' was deemed to generic, so I'll just carry the patch in
> my own tree).

As one data point, 'git all' also seems too generic to me but 'git -a' doesn't. Intuition can be weird.

So if I ran the world, then having commands
	git -a diff
and
	git for-each-repo git diff
do the same thing would be fine.  Of course I don't run the world. ;-)
[...]
Show 11 quoted lines
>> One more thing that nobody brought up during the previous reviews is
>> if we want to support subset of repositories by allowing the
>> standard pathspec match mechanism.  For example,
>>
>>         git for-each-repo -d git diff --name-only -- foo/ bar/b\*z
>>
>> might be a way to ask "please find repositories match the given
>> pathspecs (i.e. foo/ bar/b\*z) and run the command in the ones that
>> are dirty".  We would need to think about how to mark the end of the
>> command though---we could borrow \; from find(1), even though find
>> is not the best example of the UI design.

In most non-git commands, "--" represents an end-of-options marker, allowing arbitrary options afterward without having to worry about escaping minus signs. So in that spirit, if this weren't a git command, I'd expect to be able to do

	for-each-repo -- git diff -- '*.c'
and have the second '--' passed verbatim to "git diff".

Unfortunately in git (imitating commands like "grep", I suppose), "--" means "paths start here". That means that with the git convention, there is only one place to pass paths to a given command.

Tracing backwards: it would be really nice to be able to do
	git for-each-repo git grep -e foo -- '*.c'
or
	git -a grep -e foo -- '*.c'

For this practical reason, it seems that paths listed after the '--' should go to the command being run. On the other hand, if I wanted to limit my for-each-repo run to repositories in two subdirectories of the cwd, I'd be tempted to try

	git for-each-repo git grep -e foo -- src/ doc/

And if I wanted to limit to different file types in the repositories under each directory, it would be tempting to use

	git for-each-repo git grep -e foo -- 'src/*.c' 'doc/*.txt'

Is there a convention that would be usable today that is roughly forward-compatible with that? (To throw an example out, requiring that each pathspec passed to for-each-repo either starts with '*' or contains no wildcards.)

Thanks, Jonathan

Previous: Lars HjemliNext: Lars Hjemli
Message 7 of 18 in “for-each-repo: new command for multi-repo operations”
  1. 0/2 for-each-repo: new command for multi-repo operationsLars Hjemli, Jan 27, 2013
  2. 1/2 for-each-repo: new command used for multi-repo operationsLars Hjemli, Jan 27, 2013
  3. Junio C HamanoJan 27, 2013
  4. John KeepingJan 27, 2013
  5. Junio C HamanoJan 27, 2013
  6. Lars HjemliJan 28, 2013
  7. Jonathan NiederJan 28, 2013
  8. Lars HjemliJan 28, 2013
  9. Junio C HamanoJan 28, 2013
  10. Junio C HamanoJan 28, 2013
  11. Lars HjemliJan 28, 2013
  12. Junio C HamanoJan 28, 2013
  13. Lars HjemliJan 28, 2013
  14. Jens LehmannJan 28, 2013
  15. Junio C HamanoJan 28, 2013
  16. Jens LehmannJan 28, 2013
  17. Junio C HamanoFeb 4, 2013
  18. 2/2 git: rewrite `git -a` to become a git-for-each-repo commandLars Hjemli, Jan 27, 2013

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.