aboutsummaryrefslogtreecommitdiff
path: root/perl/Git
diff options
context:
space:
mode:
authorPaul Walmsley <pjwhams@gmail.com>2013-05-04 00:10:18 +0100
committerEric Wong <normalperson@yhbt.net>2013-05-09 01:13:36 +0000
commita7b102302ad9495fb4eb5088ffcb09c44a406c06 (patch)
treed09331d68889086584bd535f701bd2f31f3ca6e6 /perl/Git
parentd301f18160a3b0c3a5f647b9786aefd720d57faf (diff)
downloadgit-a7b102302ad9495fb4eb5088ffcb09c44a406c06.tar.gz
git-a7b102302ad9495fb4eb5088ffcb09c44a406c06.tar.xz
git-svn: added an --include-path flag
The SVN::Fetcher module is now able to filter for inclusion as well as exclusion (as used by --ignore-path). Also added tests, documentation changes and git completion script. If you have an SVN repository with many top level directories and you only want a git-svn clone of some of them then using --ignore-path is difficult as it requires a very long regexp. In this case it's much easier to filter for inclusion. [ew: remove trailing whitespace] Signed-off-by: Paul Walmsley <pjwhams@gmail.com> Signed-off-by: Eric Wong <normalperson@yhbt.net>
Diffstat (limited to 'perl/Git')
-rw-r--r--perl/Git/SVN/Fetcher.pm16
1 files changed, 14 insertions, 2 deletions
diff --git a/perl/Git/SVN/Fetcher.pm b/perl/Git/SVN/Fetcher.pm
index 72150af68..bd174189b 100644
--- a/perl/Git/SVN/Fetcher.pm
+++ b/perl/Git/SVN/Fetcher.pm
@@ -1,6 +1,7 @@
package Git::SVN::Fetcher;
-use vars qw/@ISA $_ignore_regex $_preserve_empty_dirs $_placeholder_filename
- @deleted_gpath %added_placeholder $repo_id/;
+use vars qw/@ISA $_ignore_regex $_include_regex $_preserve_empty_dirs
+ $_placeholder_filename @deleted_gpath %added_placeholder
+ $repo_id/;
use strict;
use warnings;
use SVN::Delta;
@@ -33,6 +34,10 @@ sub new {
my $v = eval { command_oneline('config', '--get', $k) };
$self->{ignore_regex} = $v;
+ $k = "svn-remote.$repo_id.include-paths";
+ $v = eval { command_oneline('config', '--get', $k) };
+ $self->{include_regex} = $v;
+
$k = "svn-remote.$repo_id.preserve-empty-dirs";
$v = eval { command_oneline('config', '--get', '--bool', $k) };
if ($v && $v eq 'true') {
@@ -117,11 +122,18 @@ sub in_dot_git {
}
# return value: 0 -- don't ignore, 1 -- ignore
+# This will also check whether the path is explicitly included
sub is_path_ignored {
my ($self, $path) = @_;
return 1 if in_dot_git($path);
return 1 if defined($self->{ignore_regex}) &&
$path =~ m!$self->{ignore_regex}!;
+ return 0 if defined($self->{include_regex}) &&
+ $path =~ m!$self->{include_regex}!;
+ return 0 if defined($_include_regex) &&
+ $path =~ m!$_include_regex!;
+ return 1 if defined($self->{include_regex});
+ return 1 if defined($_include_regex);
return 0 unless defined($_ignore_regex);
return 1 if $path =~ m!$_ignore_regex!o;
return 0;