7 use Config qw/%Config/;
9 use File::Spec::Functions qw/catfile path/;
12 use App::Rgit::Utils qw/:levels/;
13 use App::Rgit::Policy;
26 : ( /^-([DIKV]+)$/ ? do { $opts{$_} = 1 for split //, $1; () }
27 : do { $cmd = $_ unless /^-/; $_ } )
29 $cmd = ' ' unless defined $cmd;
35 $policy = 'Interactive';
39 $policy = eval { App::Rgit::Policy->new(name => $policy) };
40 if (not defined $policy) {
41 print STDERR $@ if $@;
42 $policy = App::Rgit::Policy->new(name => 'Default');
45 setpgrp 0, 0 if $Config{d_setpgrp};
47 my $git = $ENV{GIT_EXEC_PATH};
48 unless (defined $git) {
50 my $g = catfile $_, 'git';
57 croak "Couldn't find any valid git executable" unless defined $git;
59 my $root = $ENV{GIT_DIR};
60 $root = cwd unless defined $root;
62 my $ar = App::Rgit->new(
68 debug => $opts{D} ? INFO : WARN,
71 print STDOUT "rgit $VERSION\n" if $opts{V};
79 rgit - Recursively execute a command on all the git repositories in a directory tree.
87 rgit [-K|-I|-D|-V] [GIT_OPTIONS] COMMAND [COMMAND_ARGS]
91 This utility recursively searches in a root directory (which may be the current working directory or - if it has been set - the directory given by the C<GIT_DIR> environment variable) for all git repositories, sort this list by the repository path, C<chdir> into each of them, and executes the specified git command.
92 For efficiency reasons, repositories located inside another repository won't be searched for.
94 Moreover, those formats are substituted in the arguments before running the command :
100 C<%n> with the current repository name.
104 C<%g> with the relative path (based from the root directory) to the current repository.
108 C<%G> with the absolute path to the current repository.
112 C<%w> with the relative path (based from the root directory) to the current repository's working directory.
116 C<%W> with the absolute path to the current repository's working directory.
120 C<%b> with a "bareified" relative path, i.e. C<%g> if this is a bare repository, and C<%w.git> otherwise.
124 C<%B> with an absolute version of the "bareified" path.
128 C<%R> with the absolute path to the root directory.
132 C<%%> with a bare C<%>.
136 There are actually a few commands that are only executed once in the root directory : C<daemon>, C<gui>, C<help>, C<init> and C<version>.
137 For any of those, no format substitution is done.
139 You can specify which C<git> executable to use with the C<GIT_EXEC_PATH> environment variable.
141 =head1 COMMAND LINE SWITCHES
143 C<rgit> takes its options as the capital switches that comes before the git command.
144 It's possible to bundle them together.
145 They are removed from the argument list before calling C<git>.
153 Keep processing on error.
154 The default policy is to stop whenever an error occured.
160 Enables interactive mode when the standard input is a tty.
161 Requires L<Term::ReadKey> to be installed.
162 This lets you choose interactively what to do when one of the commands returns a non-zero status.
180 Execute C<git gc> on all the repositories below the current directory :
184 Tag all the repositories with their name :
188 Add a remote to all repositories in "/foo/bar" to their bare counterpart in C<qux> on F<host> :
190 GIT_DIR="/foo/bar" rgit remote add host git://host/qux/%b
194 The core modules L<Carp>, L<Config>, L<Cwd>, L<Exporter>, L<File::Find>, L<File::Spec::Functions> and L<POSIX>.
198 Vincent Pit, C<< <perl at profvince.com> >>, L<http://profvince.com>.
200 You can contact me by mail or on C<irc.perl.org> (vincent).
204 Please report any bugs or feature requests to C<bug-rgit at rt.cpan.org>, or through the web interface at L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=rgit>. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.
208 You can find documentation for this module with the perldoc command.
212 Tests code coverage report is available at L<http://www.profvince.com/perl/cover/rgit>.
214 =head1 COPYRIGHT & LICENSE
216 Copyright 2008-2009 Vincent Pit, all rights reserved.
218 This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.