The Perl and Raku Conference 2025: Greenville, South Carolina - June 27-29 Learn more

#!/usr/bin/env perl
our $VERSION = $App::GitFind::VERSION; # for Getopt::Long auto_version
exit App::GitFind->new(\@ARGV)->run;
__END__
# === Documentation === {{{1
=head1 NAME
git-find - Find files anywhere in a Git repository
=head1 SYNOPSIS
git find [SWITCHES] [REFS] [--] [EXPRESSION]
This command searches for files satisfying the C<EXPRESSION>, a la find(1),
anywhere in a Git repo. Unlike find(1), the search scope is the whole repo
(for the C<REFS> you specify) regardless of the current directory.
For more help, run C<git find --help> or C<git find --man>.
=head1 OPTIONS AND ARGUMENTS
Quick reference:
=over
=item Switches:
Help (-?, --usage; -h, --help; --man); Version (-V, --version);
Verbosity (-v); Warnings (-W).
=item Refs:
Anything accepted by git-rev-parse(1)
=item Expression:
Anything accepted by find(1), plus -ref/-rev
=back
=head1 DESCRIPTION
=head2 Switches
These are options controlling the overall behaviour of git-find. They may
not be interleaved in with the L</Expression>, if one is given.
=over
=item B<-?>, B<--usage>
Print a brief usage reminder
=item B<-h>, B<--help>
Print basic help
=item B<--man>
Show full help (equivalent to C<man git-find>)
=item B<-u>
Unrestricted search. Normally, git-find does not search ignored files.
When this option is given, it does search those files. However, it still
skips C<.git/> directories.
=item B<-v>
Increase verbosity. May be given multiple times.
=item B<-V>, B<--version>
Print version information and exit
=item B<-W>, B<-Wname>
Enable warning B<name>, or all warnings if no B<name> is given.
=back
=head2 Operators
In the L</Refs> or L</Expression>, you can specify multiple items joined by
logical operators. They are listed below in order of descending precedence.
Each operator must be separated by whitespace from any adjacent parameters.
Operators short-circuit.
=over
=item B<( )>, B<[ ]>
Grouping. Parentheses and brackets are interchangeable.
=item B<-not>, B<--not>, B<!>, B<^>
Logical negation.
=item B<-a>, B<--a>, B<-and>, B<--and>, B<&&>
Logical and. This is the default operator between terms if no operator
is given.
=item B<-o>, B<--o>, B<-or>, B<--or>, B<||>
Logical or
=item B<,>
Sequence: separates items to be evaluated separately. The return value
is that of the last item in the sequence.
=back
=head2 Refs
By default, git-find searches the current index (cache). This is the same
as the default for git-ls-files(1).
You can specify one or more refs to search using any of the forms described
You can specify the special value C<]]> (a double right bracket) to search
the working tree that is currently checked out.
(Mnemonic: search I<right> here.) If you have an actual ref called "]]",
git-find won't be able to help you. Sorry!
TODO? You can specify multiple ranges of refs separated by C<-o> (or its
equivalent forms given in L</Operators>) or C<,>. Comma is treated as
equivalent to C<-o> when separating refs.
=head2 Expression
The expression includes one or more elements separated by L</Operators>.
Elements can be options, tests, or operators.
Elements of expressions can be specified in a form similar to find(1).
Long elements (e.g., C<-name>) can start with a single or a double dash.
Tests are of two types:
=over
=item Index tests
These are tests that only require information from the git index, such
as the name of the file and whether it is executable. They are (at least on
Unix-like systems):
C<-cmin>, C<-cnewer>, C<-ctime>, C<-empty>, C<-executable>, C<-false>, C<-gid>,
C<-group>, C<-ilname>, C<-iname>, C<-inum>, C<-ipath>, C<-iregex>,
C<-iwholename>, C<-level>, C<-mmin>, C<-mtime>, C<-name>, C<-nogroup>,
C<-nouser>, C<-path>, C<-readable>, C<-regex>, C<-size>, C<-true>, C<-type>,
C<-uid>, C<-user>, C<-wholename>, C<-writeable>
TODO also -links, -lname, -perm, -samefile, -xtype?
=item Detailed tests
All tests other than index tests may require
checking out a worktree with one or more of the given refs.
Therefore, they may be much slower than name-only tests. However, if the only
ref given is C<]]> (working directory), detailed tests can be executed without
checking out a worktree, so the slowdown is not as bad.
=back
=head1 DIFFERENCES FROM FIND(1)
In git-find but not in find(1): -ref, -rev
In find(1) but not in git-find: find switches; TODO -xtype, -context?
=head1 WARNINGS
If the C<-W> option is given, warnings are enabled. Possible warnings are:
=over
=item B<-Wdetailed>
Warn if a detailed test is used on a search scope other than C<]]> (the
current working tree).
=back
=head1 AUTHOR
Christopher White, C<< <cxw at cpan.org> >>
=head1 BUGS
Please report any bugs or feature requests through the GitHub interface at
L<https://github.com/cxw42/git-find/issues>. I will be notified, and then
you'll automatically be notified of progress on your bug as I make changes.
=head1 SUPPORT
You can find documentation for this module with the perldoc command.
perldoc App::GitFind
You can also look for information at:
=over 4
=item * GitHub (report bugs here)
=item * MetaCPAN
=back
=head1 LICENSE AND COPYRIGHT
Copyright 2019 Christopher White.
Portions copyright 2019 D3 Engineering, LLC.
This program is distributed under the MIT (X11) License:
Permission is hereby granted, free of charge, to any person
obtaining a copy of this software and associated documentation
files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use,
copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following
conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE.
=cut
# }}}1
# vi: set fdm=marker: #