1
0
mirror of https://github.com/git/git.git synced 2024-09-29 20:13:27 +02:00
git/perl/Git/Error.pm
Ævar Arnfjörð Bjarmason 805a378649 perl: avoid *.pmc and fix Error.pm further
The previous round tried to use *.pmc files but it confused RPM
dependency analysis on some distros.  Install them as plain
vanilla *.pm files instead.

Also "local @_" construct did not properly work when goto &sub
is used until recent versions of Perl.  Avoid it (and we do not
need to localize it here anyway).

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2017-12-28 10:35:21 -08:00

47 lines
1.0 KiB
Perl

package Git::Error;
use 5.008;
use strict;
use warnings;
=head1 NAME
Git::Error - Wrapper for the L<Error> module, in case it's not installed
=head1 DESCRIPTION
Wraps the import function for the L<Error> module.
This module is only intended to be used for code shipping in the
C<git.git> repository. Use it for anything else at your peril!
=cut
sub import {
shift;
my $caller = caller;
eval {
require Error;
1;
} or do {
my $error = $@ || "Zombie Error";
my $Git_Error_pm_path = $INC{"Git/Error.pm"} || die "BUG: Should have our own path from %INC!";
require File::Basename;
my $Git_Error_pm_root = File::Basename::dirname($Git_Error_pm_path) || die "BUG: Can't figure out lib/Git dirname from '$Git_Error_pm_path'!";
require File::Spec;
my $Git_pm_FromCPAN_root = File::Spec->catdir($Git_Error_pm_root, 'FromCPAN');
die "BUG: '$Git_pm_FromCPAN_root' should be a directory!" unless -d $Git_pm_FromCPAN_root;
local @INC = ($Git_pm_FromCPAN_root, @INC);
require Error;
};
unshift @_, $caller;
goto &Error::import;
}
1;