Skip to content

Commit

Permalink
perl: move CPAN loader wrappers to another namespace
Browse files Browse the repository at this point in the history
Move the Git::Error and Git::Mail::Address wrappers to the
Git::LoadCPAN::Loader::* namespace, e.g. Git::LoadCPAN::Error. That
module will then either load Error from CPAN (if installed on the OS),
or use Git::FromCPAN::Error.

When I added the Error wrapper in 20d2a30 ("Makefile: replace
perl/Makefile.PL with simple make rules", 2017-12-10) I didn't think
about how confusing it would be to have these modules sitting in the
same tree as our normal modules. Let's put these all into
Git::{Load,From}CPAN::* to clearly distinguish them from the rest.

This also makes things a bit less confusing since there was already a
Git::Error namespace ever since 8b9150e ("Git.pm: Handle failed
commands' output", 2006-06-24).

Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
avar authored and gitster committed Mar 5, 2018
1 parent 10cf3b0 commit 2865467
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion contrib/examples/git-difftool.perl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
use 5.008;
use strict;
use warnings;
use Git::Error qw(:try);
use Git::LoadCPAN::Error qw(:try);
use File::Basename qw(dirname);
use File::Copy;
use File::Find;
Expand Down
4 changes: 2 additions & 2 deletions git-send-email.perl
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,13 @@
use Term::ANSIColor;
use File::Temp qw/ tempdir tempfile /;
use File::Spec::Functions qw(catdir catfile);
use Git::Error qw(:try);
use Git::LoadCPAN::Error qw(:try);
use Cwd qw(abs_path cwd);
use Git;
use Git::I18N;
use Git::Mail::Address;
use Net::Domain ();
use Net::SMTP ();
use Git::LoadCPAN::Mail::Address;

Getopt::Long::Configure qw/ pass_through /;

Expand Down
2 changes: 1 addition & 1 deletion perl/Git.pm
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ increase notwithstanding).


use Carp qw(carp croak); # but croak is bad - throw instead
use Git::Error qw(:try);
use Git::LoadCPAN::Error qw(:try);
use Cwd qw(abs_path cwd);
use IPC::Open2 qw(open2);
use Fcntl qw(SEEK_SET SEEK_CUR);
Expand Down
8 changes: 4 additions & 4 deletions perl/Git/Error.pm → perl/Git/LoadCPAN/Error.pm
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package Git::Error;
package Git::LoadCPAN::Error;
use 5.008;
use strict;
use warnings;

=head1 NAME
Git::Error - Wrapper for the L<Error> module, in case it's not installed
Git::LoadCPAN::Error - Wrapper for the L<Error> module, in case it's not installed
=head1 DESCRIPTION
Expand All @@ -26,13 +26,13 @@ sub import {
} or do {
my $error = $@ || "Zombie Error";

my $Git_Error_pm_path = $INC{"Git/Error.pm"} || die "BUG: Should have our own path from %INC!";
my $Git_Error_pm_path = $INC{"Git/LoadCPAN/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');
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);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package Git::Mail::Address;
package Git::LoadCPAN::Mail::Address;
use 5.008;
use strict;
use warnings;

=head1 NAME
Git::Mail::Address - Wrapper for the L<Mail::Address> module, in case it's not installed
Git::LoadCPAN::Mail::Address - Wrapper for the L<Mail::Address> module, in case it's not installed
=head1 DESCRIPTION
Expand Down

0 comments on commit 2865467

Please sign in to comment.