70
70
$Git::SVN::_follow_parent = 1;
71
71
my %remote_opts = ( ' username=s' => \$Git::SVN::Prompt::_username ,
72
72
' config-dir=s' => \$Git::SVN::Ra::config_dir ,
73
- ' no-auth-cache' => \$Git::SVN::Prompt::_no_auth_cache );
73
+ ' no-auth-cache' => \$Git::SVN::Prompt::_no_auth_cache ,
74
+ ' ignore-paths=s' => \$SVN::Git::Fetcher::_ignore_regex );
74
75
my %fc_opts = ( ' follow-parent|follow!' => \$Git::SVN::_follow_parent ,
75
76
' authors-file|A=s' => \$_authors,
76
77
' repack:i' => \$Git::SVN::_repack ,
@@ -3245,6 +3246,7 @@ package SVN::Git::Fetcher;
3245
3246
use Carp qw/ croak/ ;
3246
3247
use File::Temp qw/ tempfile/ ;
3247
3248
use IO::File qw/ / ;
3249
+ use vars qw/ $_ignore_regex/ ;
3248
3250
3249
3251
# file baton members: path, mode_a, mode_b, pool, fh, blob, base
3250
3252
sub new {
@@ -3297,6 +3299,15 @@ sub in_dot_git {
3297
3299
$_ [0] =~ m { (?:^|/)\. git(?:/|$) } ;
3298
3300
}
3299
3301
3302
+ # return value: 0 -- don't ignore, 1 -- ignore
3303
+ sub is_path_ignored {
3304
+ my ($path ) = @_ ;
3305
+ return 1 if in_dot_git($path );
3306
+ return 0 unless defined ($_ignore_regex);
3307
+ return 1 if $path =~ m !$ _ignore_regex! o ;
3308
+ return 0;
3309
+ }
3310
+
3300
3311
sub set_path_strip {
3301
3312
my ($self , $path ) = @_ ;
3302
3313
$self -> {path_strip } = qr / ^\Q $path \E (\/ |$ )/ if length $path ;
@@ -3322,7 +3333,7 @@ sub git_path {
3322
3333
3323
3334
sub delete_entry {
3324
3335
my ($self , $path , $rev , $pb ) = @_ ;
3325
- return undef if in_dot_git ($path );
3336
+ return undef if is_path_ignored ($path );
3326
3337
3327
3338
my $gpath = $self -> git_path($path );
3328
3339
return undef if ($gpath eq ' ' );
@@ -3352,7 +3363,7 @@ sub open_file {
3352
3363
my ($self , $path , $pb , $rev ) = @_ ;
3353
3364
my ($mode , $blob );
3354
3365
3355
- goto out if in_dot_git ($path );
3366
+ goto out if is_path_ignored ($path );
3356
3367
3357
3368
my $gpath = $self -> git_path($path );
3358
3369
($mode , $blob ) = (command(' ls-tree' , $self -> {c }, ' --' , $gpath )
@@ -3372,7 +3383,7 @@ sub add_file {
3372
3383
my ($self , $path , $pb , $cp_path , $cp_rev ) = @_ ;
3373
3384
my $mode ;
3374
3385
3375
- if (!in_dot_git ($path )) {
3386
+ if (!is_path_ignored ($path )) {
3376
3387
my ($dir , $file ) = ($path =~ m # ^(.*?)/?([^/]+)$ # );
3377
3388
delete $self -> {empty }-> {$dir };
3378
3389
$mode = ' 100644' ;
@@ -3383,7 +3394,7 @@ sub add_file {
3383
3394
3384
3395
sub add_directory {
3385
3396
my ($self , $path , $cp_path , $cp_rev ) = @_ ;
3386
- goto out if in_dot_git ($path );
3397
+ goto out if is_path_ignored ($path );
3387
3398
my $gpath = $self -> git_path($path );
3388
3399
if ($gpath eq ' ' ) {
3389
3400
my ($ls , $ctx ) = command_output_pipe(qw/ ls-tree
@@ -3407,31 +3418,31 @@ sub add_directory {
3407
3418
3408
3419
sub change_dir_prop {
3409
3420
my ($self , $db , $prop , $value ) = @_ ;
3410
- return undef if in_dot_git ($db -> {path });
3421
+ return undef if is_path_ignored ($db -> {path });
3411
3422
$self -> {dir_prop }-> {$db -> {path }} ||= {};
3412
3423
$self -> {dir_prop }-> {$db -> {path }}-> {$prop } = $value ;
3413
3424
undef ;
3414
3425
}
3415
3426
3416
3427
sub absent_directory {
3417
3428
my ($self , $path , $pb ) = @_ ;
3418
- return undef if in_dot_git( $pb -> { path } );
3429
+ return undef if is_path_ignored( $ path );
3419
3430
$self -> {absent_dir }-> {$pb -> {path }} ||= [];
3420
3431
push @{$self -> {absent_dir }-> {$pb -> {path }}}, $path ;
3421
3432
undef ;
3422
3433
}
3423
3434
3424
3435
sub absent_file {
3425
3436
my ($self , $path , $pb ) = @_ ;
3426
- return undef if in_dot_git( $pb -> { path } );
3437
+ return undef if is_path_ignored( $ path );
3427
3438
$self -> {absent_file }-> {$pb -> {path }} ||= [];
3428
3439
push @{$self -> {absent_file }-> {$pb -> {path }}}, $path ;
3429
3440
undef ;
3430
3441
}
3431
3442
3432
3443
sub change_file_prop {
3433
3444
my ($self , $fb , $prop , $value ) = @_ ;
3434
- return undef if in_dot_git ($fb -> {path });
3445
+ return undef if is_path_ignored ($fb -> {path });
3435
3446
if ($prop eq ' svn:executable' ) {
3436
3447
if ($fb -> {mode_b } != 120000) {
3437
3448
$fb -> {mode_b } = defined $value ? 100755 : 100644;
@@ -3447,7 +3458,7 @@ sub change_file_prop {
3447
3458
3448
3459
sub apply_textdelta {
3449
3460
my ($self , $fb , $exp ) = @_ ;
3450
- return undef if (in_dot_git( $fb -> {path }) );
3461
+ return undef if is_path_ignored( $fb -> {path });
3451
3462
my $fh = $: :_repository-> temp_acquire(' svn_delta' );
3452
3463
# $fh gets auto-closed() by SVN::TxDelta::apply(),
3453
3464
# (but $base does not,) so dup() it for reading in close_file
@@ -3494,7 +3505,7 @@ sub apply_textdelta {
3494
3505
3495
3506
sub close_file {
3496
3507
my ($self , $fb , $exp ) = @_ ;
3497
- return undef if (in_dot_git( $fb -> {path }) );
3508
+ return undef if is_path_ignored( $fb -> {path });
3498
3509
3499
3510
my $hash ;
3500
3511
my $path = $self -> git_path($fb -> {path });
@@ -4021,7 +4032,8 @@ package Git::SVN::Ra;
4021
4032
BEGIN {
4022
4033
# enforce temporary pool usage for some simple functions
4023
4034
no strict ' refs' ;
4024
- for my $f (qw/ rev_proplist get_latest_revnum get_uuid get_repos_root/ ) {
4035
+ for my $f (qw/ rev_proplist get_latest_revnum get_uuid get_repos_root
4036
+ get_file/ ) {
4025
4037
my $SUPER = " SUPER::$f " ;
4026
4038
*$f = sub {
4027
4039
my $self = shift ;
0 commit comments