3 #=======================================================================
5 # File ID: 43e51bbe-2825-11e5-9340-000df06acc56
10 # ©opyleft 2015– Øyvind A. Holm <sunny@sunbase.org>
11 # License: GNU General Public License version 2 or later, see end of
12 # file for legal stuff.
13 #=======================================================================
31 $progname =~ s/^.*\/(.*?)$/$1/;
32 our $VERSION = '0.1.0';
34 Getopt
::Long
::Configure
('bundling');
37 'help|h' => \
$Opt{'help'},
38 'quiet|q+' => \
$Opt{'quiet'},
39 'verbose|v+' => \
$Opt{'verbose'},
40 'version' => \
$Opt{'version'},
42 ) || die("$progname: Option error. Use -h for help.\n");
44 $Opt{'verbose'} -= $Opt{'quiet'};
45 $Opt{'help'} && usage
(0);
46 if ($Opt{'version'}) {
51 my %checked = (); # Contains all potential shas checked
60 while (my $line = <>) {
62 my @result = potential_refs
($line);
63 for my $curr (@result) {
64 my $act = actual_ref
($curr);
65 if (length($act) && !$printed{"$act"}) {
80 msg
(4, "Entering potential_refs('$orig')");
85 msg
(4, "\$pot = '$pot'");
86 if (!$checked{"$pot"}) {
87 msg
(4, "'$pot' is not checked before");
93 msg
(4, "\$str afterwards: '$str'");
94 msg
(4, "scalar(retval) = '" . scalar(@retval) . "'");
95 msg
(3, "potential_refs('$orig') returns ['" . join("', '", @retval) . "']");
101 chomp(my $result = `git rev-parse --quiet --verify $ref`);
102 msg
(4, "is_actual_ref(): \$result = '$result'");
103 my $retval = ($result =~ /^[0-9a-f]{40}/) ?
$result : '';
104 msg
(4, "is_actual_ref('$ref') returns '$retval'");
109 # Print program version {{{
110 print("$progname $VERSION\n");
116 # Send the help message to stdout {{{
119 if ($Opt{'verbose'}) {
125 Usage: $progname [options] [file [files [...]]]
132 Be more quiet. Can be repeated to increase silence.
134 Increase level of verbosity. Can be repeated.
136 Print version information.
144 # Print a status message to stderr based on verbosity level {{{
145 my ($verbose_level, $Txt) = @_;
147 if ($Opt{'verbose'} >= $verbose_level) {
148 print(STDERR
"$progname: $Txt\n");
156 # This program is free software; you can redistribute it and/or modify
157 # it under the terms of the GNU General Public License as published by
158 # the Free Software Foundation; either version 2 of the License, or (at
159 # your option) any later version.
161 # This program is distributed in the hope that it will be useful, but
162 # WITHOUT ANY WARRANTY; without even the implied warranty of
163 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
164 # See the GNU General Public License for more details.
166 # You should have received a copy of the GNU General Public License
167 # along with this program.
168 # If not, see L<http://www.gnu.org/licenses/>.
170 # vim: set fenc=UTF-8 ft=perl fdm=marker ts=4 sw=4 sts=4 et fo+=w :