git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 1/2] Add per-svn-remote ignore-paths config
@ 2009-04-11 17:46 Ben Jackson
  2009-04-11 17:46 ` [PATCH v2 2/2] Save init/clone --ignore-paths option as svn-remotes.svn.ignore-paths Ben Jackson
  2009-04-12  0:59 ` [PATCH v2 1/2] Add per-svn-remote ignore-paths config Eric Wong
  0 siblings, 2 replies; 4+ messages in thread
From: Ben Jackson @ 2009-04-11 17:46 UTC (permalink / raw)
  To: git; +Cc: normalperson, gitster, ben

The --ignore-paths option to fetch is very useful for working on a subset
of a SVN repository.  For proper operation, every command that causes a
fetch (explicit or implied) must include a matching --ignore-paths option.

This patch adds a persistent svn-remote.$repo_id.ignore-paths config by
promoting Fetcher::is_path_ignored to a member function and initializing
$self->{ignore_regex} in Fetcher::new.  Command line --ignore-paths is
still recognized and acts in addition to the config value.

Signed-off-by: Ben Jackson <ben@ben.com>
---

This version fixes a bug found by Eric Wong (inappropriate cut'n'paste
use of perl m//o) and extends the test cases to include independent
tests for command-line and config ignore-paths.

 Documentation/git-svn.txt       |   22 ++++++++++-----
 git-svn.perl                    |   26 ++++++++++--------
 t/t9134-git-svn-ignore-paths.sh |   55 ++++++++++++++++++++++++++++++++++++--
 3 files changed, 82 insertions(+), 21 deletions(-)

diff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt
index b7b1af8..af2d6c2 100644
--- a/Documentation/git-svn.txt
+++ b/Documentation/git-svn.txt
@@ -104,17 +104,25 @@ repository, either don't use this option or you should both use it in
 the same local timezone.
 
 --ignore-paths=<regex>;;
-	This allows one to specify Perl regular expression that will
+	This allows one to specify a Perl regular expression that will
 	cause skipping of all matching paths from checkout from SVN.
-	Examples:
+	The '--ignore-paths' option should match for every 'fetch'
+	(including automatic fetches due to 'clone', 'dcommit',
+	'rebase', etc) on a given repository.
 
-	--ignore-paths="^doc" - skip "doc*" directory for every fetch.
+config key: svn-remote.<name>.ignore-paths
 
-	--ignore-paths="^[^/]+/(?:branches|tags)" - skip "branches"
-	    and "tags" of first level directories.
+	If the ignore-paths config key is set and the command
+	line option is also given, both regular expressions
+	will be used.
 
-	Regular expression is not persistent, you should specify
-	it every time when fetching.
+Examples:
+
+	--ignore-paths="^doc" - skip "doc*" directory for every
+	    fetch.
+
+	--ignore-paths="^[^/]+/(?:branches|tags)" - skip
+	    "branches" and "tags" of first level directories.
 
 'clone'::
 	Runs 'init' and 'fetch'.  It will automatically create a
diff --git a/git-svn.perl b/git-svn.perl
index d919798..8e195ed 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -3286,6 +3286,8 @@ sub new {
 		$self->{empty_symlinks} =
 		                  _mark_empty_symlinks($git_svn, $switch_path);
 	}
+	$self->{ignore_regex} = eval { command_oneline('config', '--get',
+			     "svn-remote.$git_svn->{repo_id}.ignore-paths") };
 	$self->{empty} = {};
 	$self->{dir_prop} = {};
 	$self->{file_prop} = {};
@@ -3350,8 +3352,10 @@ sub in_dot_git {
 
 # return value: 0 -- don't ignore, 1 -- ignore
 sub is_path_ignored {
-	my ($path) = @_;
+	my ($self, $path) = @_;
 	return 1 if in_dot_git($path);
+	return 1 if defined($self->{ignore_regex}) &&
+	            $path =~ m!$self->{ignore_regex}!;
 	return 0 unless defined($_ignore_regex);
 	return 1 if $path =~ m!$_ignore_regex!o;
 	return 0;
@@ -3382,7 +3386,7 @@ sub git_path {
 
 sub delete_entry {
 	my ($self, $path, $rev, $pb) = @_;
-	return undef if is_path_ignored($path);
+	return undef if $self->is_path_ignored($path);
 
 	my $gpath = $self->git_path($path);
 	return undef if ($gpath eq '');
@@ -3415,7 +3419,7 @@ sub open_file {
 	my ($self, $path, $pb, $rev) = @_;
 	my ($mode, $blob);
 
-	goto out if is_path_ignored($path);
+	goto out if $self->is_path_ignored($path);
 
 	my $gpath = $self->git_path($path);
 	($mode, $blob) = (command('ls-tree', '-z', $self->{c}, "./$gpath")
@@ -3435,7 +3439,7 @@ sub add_file {
 	my ($self, $path, $pb, $cp_path, $cp_rev) = @_;
 	my $mode;
 
-	if (!is_path_ignored($path)) {
+	if (!$self->is_path_ignored($path)) {
 		my ($dir, $file) = ($path =~ m#^(.*?)/?([^/]+)$#);
 		delete $self->{empty}->{$dir};
 		$mode = '100644';
@@ -3446,7 +3450,7 @@ sub add_file {
 
 sub add_directory {
 	my ($self, $path, $cp_path, $cp_rev) = @_;
-	goto out if is_path_ignored($path);
+	goto out if $self->is_path_ignored($path);
 	my $gpath = $self->git_path($path);
 	if ($gpath eq '') {
 		my ($ls, $ctx) = command_output_pipe(qw/ls-tree
@@ -3470,7 +3474,7 @@ out:
 
 sub change_dir_prop {
 	my ($self, $db, $prop, $value) = @_;
-	return undef if is_path_ignored($db->{path});
+	return undef if $self->is_path_ignored($db->{path});
 	$self->{dir_prop}->{$db->{path}} ||= {};
 	$self->{dir_prop}->{$db->{path}}->{$prop} = $value;
 	undef;
@@ -3478,7 +3482,7 @@ sub change_dir_prop {
 
 sub absent_directory {
 	my ($self, $path, $pb) = @_;
-	return undef if is_path_ignored($path);
+	return undef if $self->is_path_ignored($path);
 	$self->{absent_dir}->{$pb->{path}} ||= [];
 	push @{$self->{absent_dir}->{$pb->{path}}}, $path;
 	undef;
@@ -3486,7 +3490,7 @@ sub absent_directory {
 
 sub absent_file {
 	my ($self, $path, $pb) = @_;
-	return undef if is_path_ignored($path);
+	return undef if $self->is_path_ignored($path);
 	$self->{absent_file}->{$pb->{path}} ||= [];
 	push @{$self->{absent_file}->{$pb->{path}}}, $path;
 	undef;
@@ -3494,7 +3498,7 @@ sub absent_file {
 
 sub change_file_prop {
 	my ($self, $fb, $prop, $value) = @_;
-	return undef if is_path_ignored($fb->{path});
+	return undef if $self->is_path_ignored($fb->{path});
 	if ($prop eq 'svn:executable') {
 		if ($fb->{mode_b} != 120000) {
 			$fb->{mode_b} = defined $value ? 100755 : 100644;
@@ -3510,7 +3514,7 @@ sub change_file_prop {
 
 sub apply_textdelta {
 	my ($self, $fb, $exp) = @_;
-	return undef if is_path_ignored($fb->{path});
+	return undef if $self->is_path_ignored($fb->{path});
 	my $fh = $::_repository->temp_acquire('svn_delta');
 	# $fh gets auto-closed() by SVN::TxDelta::apply(),
 	# (but $base does not,) so dup() it for reading in close_file
@@ -3557,7 +3561,7 @@ sub apply_textdelta {
 
 sub close_file {
 	my ($self, $fb, $exp) = @_;
-	return undef if is_path_ignored($fb->{path});
+	return undef if $self->is_path_ignored($fb->{path});
 
 	my $hash;
 	my $path = $self->git_path($fb->{path});
diff --git a/t/t9134-git-svn-ignore-paths.sh b/t/t9134-git-svn-ignore-paths.sh
index c4b5b8b..b9a1597 100755
--- a/t/t9134-git-svn-ignore-paths.sh
+++ b/t/t9134-git-svn-ignore-paths.sh
@@ -31,6 +31,22 @@ test_expect_success 'clone an SVN repository with ignored www directory' '
 	test_cmp expect expect2
 '
 
+test_expect_success 'init+fetch an SVN repository with ignored www directory' '
+	git svn init "$svnrepo" c &&
+	( cd c && git svn fetch --ignore-paths="^www" ) &&
+	rm expect2 &&
+	echo test_qqq > expect &&
+	for i in c/*/*.txt; do cat $i >> expect2; done &&
+	test_cmp expect expect2
+'
+
+test_expect_success 'set persistent ignore-paths config' '
+	(
+	    cd g &&
+	    git config svn-remote.svn.ignore-paths "^www"
+	)
+'
+
 test_expect_success 'SVN-side change outside of www' '
 	(
 		cd s &&
@@ -41,9 +57,20 @@ test_expect_success 'SVN-side change outside of www' '
 	)
 '
 
-test_expect_success 'update git svn-cloned repo' '
+test_expect_success 'update git svn-cloned repo (config ignore)' '
 	(
 		cd g &&
+		git svn rebase &&
+		printf "test_qqq\nb\n" > expect &&
+		for i in */*.txt; do cat $i >> expect2; done &&
+		test_cmp expect2 expect &&
+		rm expect expect2
+	)
+'
+
+test_expect_success 'update git svn-cloned repo (option ignore)' '
+	(
+		cd c &&
 		git svn rebase --ignore-paths="^www" &&
 		printf "test_qqq\nb\n" > expect &&
 		for i in */*.txt; do cat $i >> expect2; done &&
@@ -62,9 +89,20 @@ test_expect_success 'SVN-side change inside of ignored www' '
 	)
 '
 
-test_expect_success 'update git svn-cloned repo' '
+test_expect_success 'update git svn-cloned repo (config ignore)' '
 	(
 		cd g &&
+		git svn rebase &&
+		printf "test_qqq\nb\n" > expect &&
+		for i in */*.txt; do cat $i >> expect2; done &&
+		test_cmp expect2 expect &&
+		rm expect expect2
+	)
+'
+
+test_expect_success 'update git svn-cloned repo (option ignore)' '
+	(
+		cd c &&
 		git svn rebase --ignore-paths="^www" &&
 		printf "test_qqq\nb\n" > expect &&
 		for i in */*.txt; do cat $i >> expect2; done &&
@@ -84,9 +122,20 @@ test_expect_success 'SVN-side change in and out of ignored www' '
 	)
 '
 
-test_expect_success 'update git svn-cloned repo again' '
+test_expect_success 'update git svn-cloned repo again (config ignore)' '
 	(
 		cd g &&
+		git svn rebase &&
+		printf "test_qqq\nb\nygg\n" > expect &&
+		for i in */*.txt; do cat $i >> expect2; done &&
+		test_cmp expect2 expect &&
+		rm expect expect2
+	)
+'
+
+test_expect_success 'update git svn-cloned repo again (option ignore)' '
+	(
+		cd c &&
 		git svn rebase --ignore-paths="^www" &&
 		printf "test_qqq\nb\nygg\n" > expect &&
 		for i in */*.txt; do cat $i >> expect2; done &&
-- 
1.6.2.2.487.gd6486

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] Save init/clone --ignore-paths option as svn-remotes.svn.ignore-paths
  2009-04-11 17:46 [PATCH v2 1/2] Add per-svn-remote ignore-paths config Ben Jackson
@ 2009-04-11 17:46 ` Ben Jackson
  2009-04-12  0:59 ` [PATCH v2 1/2] Add per-svn-remote ignore-paths config Eric Wong
  1 sibling, 0 replies; 4+ messages in thread
From: Ben Jackson @ 2009-04-11 17:46 UTC (permalink / raw)
  To: git; +Cc: normalperson, gitster, ben

Signed-off-by: Ben Jackson <ben@ben.com>
---
 Documentation/git-svn.txt       |    4 ++++
 git-svn.perl                    |    3 +++
 t/t9134-git-svn-ignore-paths.sh |    4 ++--
 3 files changed, 9 insertions(+), 2 deletions(-)

diff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt
index af2d6c2..cd47bff 100644
--- a/Documentation/git-svn.txt
+++ b/Documentation/git-svn.txt
@@ -85,6 +85,10 @@ COMMANDS
 	specified, the prefix must include a trailing slash.
 	Setting a prefix is useful if you wish to track multiple
 	projects that share a common repository.
+--ignore-paths=<regex>;;
+	When passed to 'init' or 'clone' this regular expression will
+	be preserved as a config key.  See 'fetch' for a description
+	of '--ignore-paths'.
 
 'fetch'::
 	Fetch unfetched revisions from the Subversion remote we are
diff --git a/git-svn.perl b/git-svn.perl
index 8e195ed..a04d158 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -334,6 +334,9 @@ sub do_git_init_db {
 		command_noisy('config', "$pfx.$i", $icv{$i});
 		$set = $i;
 	}
+	my $ignore_regex = \$SVN::Git::Fetcher::_ignore_regex;
+	command_noisy('config', "$pfx.ignore-paths", $$ignore_regex)
+		if defined $$ignore_regex;
 }
 
 sub init_subdir {
diff --git a/t/t9134-git-svn-ignore-paths.sh b/t/t9134-git-svn-ignore-paths.sh
index b9a1597..71fdc4a 100755
--- a/t/t9134-git-svn-ignore-paths.sh
+++ b/t/t9134-git-svn-ignore-paths.sh
@@ -40,10 +40,10 @@ test_expect_success 'init+fetch an SVN repository with ignored www directory' '
 	test_cmp expect expect2
 '
 
-test_expect_success 'set persistent ignore-paths config' '
+test_expect_success 'verify ignore-paths config saved by clone' '
 	(
 	    cd g &&
-	    git config svn-remote.svn.ignore-paths "^www"
+	    git config --get svn-remote.svn.ignore-paths | fgrep "www"
 	)
 '
 
-- 
1.6.2.2.487.gd6486

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/2] Add per-svn-remote ignore-paths config
  2009-04-11 17:46 [PATCH v2 1/2] Add per-svn-remote ignore-paths config Ben Jackson
  2009-04-11 17:46 ` [PATCH v2 2/2] Save init/clone --ignore-paths option as svn-remotes.svn.ignore-paths Ben Jackson
@ 2009-04-12  0:59 ` Eric Wong
  2009-04-12  8:29   ` Junio C Hamano
  1 sibling, 1 reply; 4+ messages in thread
From: Eric Wong @ 2009-04-12  0:59 UTC (permalink / raw)
  To: Junio C Hamano, Ben Jackson; +Cc: git

Ben Jackson <ben@ben.com> wrote:
> Signed-off-by: Ben Jackson <ben@ben.com>
> 
> ---
> 
> This version fixes a bug found by Eric Wong (inappropriate cut'n'paste
> use of perl m//o) and extends the test cases to include independent
> tests for command-line and config ignore-paths.

Thanks Ben, this series acked and pushed out to
git://git.bogomips.org/git-svn.git

-- 
Eric Wong

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/2] Add per-svn-remote ignore-paths config
  2009-04-12  0:59 ` [PATCH v2 1/2] Add per-svn-remote ignore-paths config Eric Wong
@ 2009-04-12  8:29   ` Junio C Hamano
  0 siblings, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2009-04-12  8:29 UTC (permalink / raw)
  To: Eric Wong; +Cc: Ben Jackson, git

Eric Wong <normalperson@yhbt.net> writes:

> Ben Jackson <ben@ben.com> wrote:
>> Signed-off-by: Ben Jackson <ben@ben.com>
>> 
>> ---
>> 
>> This version fixes a bug found by Eric Wong (inappropriate cut'n'paste
>> use of perl m//o) and extends the test cases to include independent
>> tests for command-line and config ignore-paths.
>
> Thanks Ben, this series acked and pushed out to
> git://git.bogomips.org/git-svn.git

Thanks, pulled.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-04-12  8:30 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-11 17:46 [PATCH v2 1/2] Add per-svn-remote ignore-paths config Ben Jackson
2009-04-11 17:46 ` [PATCH v2 2/2] Save init/clone --ignore-paths option as svn-remotes.svn.ignore-paths Ben Jackson
2009-04-12  0:59 ` [PATCH v2 1/2] Add per-svn-remote ignore-paths config Eric Wong
2009-04-12  8:29   ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).