line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
#!/usr/bin/env perl |
2
|
1
|
|
|
1
|
|
336
|
use App::GitFind; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
32
|
|
3
|
1
|
|
|
1
|
|
5
|
use Cwd; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
1194
|
|
4
|
1
|
|
|
|
|
3
|
our $VERSION = $App::GitFind::VERSION; # for Getopt::Long auto_version |
5
|
1
|
|
|
|
|
19
|
exit App::GitFind->new(-argv => \@ARGV, -searchbase=>getcwd)->run; |
6
|
|
|
|
|
|
|
__END__ |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# === Documentation === {{{1 |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
git-find - Find files anywhere in a Git repository |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 SYNOPSIS |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
git find [SWITCHES] [REVS] [--] [EXPRESSION] |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
This command searches for files satisfying the C<EXPRESSION>, a la find(1), |
19
|
|
|
|
|
|
|
anywhere in a Git repo. Unlike find(1), the search scope is the whole repo |
20
|
|
|
|
|
|
|
(for the C<REVS> you specify) regardless of the current directory. |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
For more help, run C<git find --help> or C<git find --man>. |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
B<NOTE:> most of this is not yet implemented :) . Contributions welcome! |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=head1 OPTIONS AND ARGUMENTS |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
Quick reference: |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=over |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=item Switches: |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
Help (-?, --usage; -h, --help; --man); Version (-V, --version); |
35
|
|
|
|
|
|
|
Verbosity (-v); Warnings (-W). |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
=item Revs: |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
Anything accepted by git-rev-parse(1). |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
A git B<ref> (under C<.git/refs/>) is also a B<rev> in the sense of |
42
|
|
|
|
|
|
|
git-rev-parse(1) and gitrevisions(7). The terms "ref" and "rev" are used |
43
|
|
|
|
|
|
|
interchangeably by C<git-find>. |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
=item Expression: |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
Anything accepted by find(1), plus -ref/-rev |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=back |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 DESCRIPTION |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 Switches |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
These are options controlling the overall behaviour of git-find. They may |
56
|
|
|
|
|
|
|
not be interleaved in with the L</Expression>, if one is given. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=over |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=item B<-?>, B<--usage> |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Print a brief usage reminder |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=item B<-h>, B<--help> |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Print basic help |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=item B<--man> |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Show full help (equivalent to C<man git-find>) |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=item B<-u> |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Unrestricted search. Normally, git-find does not search ignored files. |
75
|
|
|
|
|
|
|
When this option is given, it does search those files. However, it still |
76
|
|
|
|
|
|
|
skips C<.git/> directories. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=item B<-v> |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Increase verbosity. May be given multiple times. |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=item B<-V>, B<--version> |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
Print version information and exit |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=item B<-W>, B<-Wname> |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Enable warning B<name>, or all warnings if no B<name> is given. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=back |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head2 Operators |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
In the L</Revs> or L</Expression>, you can specify multiple items joined by |
95
|
|
|
|
|
|
|
logical operators. They are listed below in order of descending precedence. |
96
|
|
|
|
|
|
|
Each operator must be separated by whitespace from any adjacent parameters. |
97
|
|
|
|
|
|
|
Operators short-circuit. |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=over |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=item B<( )>, B<[ ]> |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Grouping. Parentheses and brackets are interchangeable. |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=item B<-not>, B<--not>, B<!>, B<^> |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Logical negation. |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=item B<-a>, B<--a>, B<-and>, B<--and>, B<&&> |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Logical and. This is the default operator between terms if no operator |
112
|
|
|
|
|
|
|
is given. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=item B<-o>, B<--o>, B<-or>, B<--or>, B<||> |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Logical or |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
=item B<,> (a single comma) |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
Sequence: separates items to be evaluated separately. The return value |
121
|
|
|
|
|
|
|
is that of the last item in the sequence. |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=back |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head2 Revs |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
By default, git-find searches the current index (cache). This is the same |
128
|
|
|
|
|
|
|
as the default for git-ls-files(1). |
129
|
|
|
|
|
|
|
You can specify one or more revs to search using any of the forms described |
130
|
|
|
|
|
|
|
in L<gitrevisions(7)|https://git-scm.com/docs/gitrevisions>. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
You can specify the special value C<]]> (a double right bracket) to search |
133
|
|
|
|
|
|
|
the working tree that is currently checked out. |
134
|
|
|
|
|
|
|
(Mnemonic: search I<right> here.) If you have an actual rev called "]]", |
135
|
|
|
|
|
|
|
git-find won't be able to help you. Sorry! |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
TODO? You can specify multiple ranges of revs separated by C<-o> (or its |
138
|
|
|
|
|
|
|
equivalent forms given in L</Operators>) or C<,>. Comma is treated as |
139
|
|
|
|
|
|
|
equivalent to C<-o> when separating revs. |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=head2 Expression |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
The expression includes one or more elements separated by L</Operators>. |
144
|
|
|
|
|
|
|
Elements can be options, tests, or operators. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
Elements of expressions can be specified in a form similar to find(1). |
147
|
|
|
|
|
|
|
Long elements (e.g., C<-name>) can start with a single or a double dash. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
Tests are of two types: |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=over |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=item Index tests |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
These are tests that only require information from the git index, such |
156
|
|
|
|
|
|
|
as the name of the file and whether it is executable. They are (at least on |
157
|
|
|
|
|
|
|
Unix-like systems): |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
C<-cmin>, C<-cnewer>, C<-ctime>, C<-empty>, C<-executable>, C<-false>, C<-gid>, |
160
|
|
|
|
|
|
|
C<-group>, C<-ilname>, C<-iname>, C<-inum>, C<-ipath>, C<-iregex>, |
161
|
|
|
|
|
|
|
C<-iwholename>, C<-level>, C<-mmin>, C<-mtime>, C<-name>, C<-nogroup>, |
162
|
|
|
|
|
|
|
C<-nouser>, C<-path>, C<-readable>, C<-regex>, C<-size>, C<-true>, C<-type>, |
163
|
|
|
|
|
|
|
C<-uid>, C<-user>, C<-wholename>, C<-writeable> |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
TODO also -links, -lname, -perm, -samefile, -xtype? |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=item Detailed tests |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
All tests other than index tests may require |
170
|
|
|
|
|
|
|
checking out a worktree with one or more of the given revs. |
171
|
|
|
|
|
|
|
Therefore, they may be much slower than name-only tests. However, if the only |
172
|
|
|
|
|
|
|
rev given is C<]]> (working directory), detailed tests can be executed without |
173
|
|
|
|
|
|
|
checking out a worktree, so the slowdown is not as bad. |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=back |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head1 DIFFERENCES FROM FIND(1) |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
In git-find but not in find(1): -ref, -rev |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
In find(1) but not in git-find: find switches; TODO -xtype, -context? |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=head1 WARNINGS |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
If the C<-W> option is given, warnings are enabled. Possible warnings are: |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=over |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=item B<-Wdetailed> |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
Warn if a detailed test is used on a search scope other than C<]]> (the |
192
|
|
|
|
|
|
|
current working tree). |
193
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
=back |
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=head1 AUTHOR |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
Christopher White, C<< <cxw at cpan.org> >> |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=head1 BUGS |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
Please report any bugs or feature requests through the GitHub interface at |
203
|
|
|
|
|
|
|
L<https://github.com/cxw42/git-find/issues>. I will be notified, and then |
204
|
|
|
|
|
|
|
you'll automatically be notified of progress on your bug as I make changes. |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=head1 SUPPORT |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
perldoc App::GitFind |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
You can also look for information at: |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
=over 4 |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
=item * GitHub (report bugs here) |
217
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
L<https://github.com/cxw42/git-find> |
219
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
=item * MetaCPAN |
221
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
L<https://metacpan.org/release/App-GitFind> |
223
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
=back |
225
|
|
|
|
|
|
|
|
226
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
227
|
|
|
|
|
|
|
|
228
|
|
|
|
|
|
|
Copyright 2019 Christopher White. |
229
|
|
|
|
|
|
|
Portions copyright 2019 D3 Engineering, LLC. |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
This program is distributed under the MIT (X11) License: |
232
|
|
|
|
|
|
|
L<http://www.opensource.org/licenses/mit-license.php> |
233
|
|
|
|
|
|
|
|
234
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person |
235
|
|
|
|
|
|
|
obtaining a copy of this software and associated documentation |
236
|
|
|
|
|
|
|
files (the "Software"), to deal in the Software without |
237
|
|
|
|
|
|
|
restriction, including without limitation the rights to use, |
238
|
|
|
|
|
|
|
copy, modify, merge, publish, distribute, sublicense, and/or sell |
239
|
|
|
|
|
|
|
copies of the Software, and to permit persons to whom the |
240
|
|
|
|
|
|
|
Software is furnished to do so, subject to the following |
241
|
|
|
|
|
|
|
conditions: |
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be |
244
|
|
|
|
|
|
|
included in all copies or substantial portions of the Software. |
245
|
|
|
|
|
|
|
|
246
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
247
|
|
|
|
|
|
|
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
248
|
|
|
|
|
|
|
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
249
|
|
|
|
|
|
|
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
250
|
|
|
|
|
|
|
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
251
|
|
|
|
|
|
|
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
252
|
|
|
|
|
|
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
253
|
|
|
|
|
|
|
OTHER DEALINGS IN THE SOFTWARE. |
254
|
|
|
|
|
|
|
|
255
|
|
|
|
|
|
|
=cut |
256
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
# }}}1 |
258
|
|
|
|
|
|
|
# vi: set fdm=marker: # |