{"thread":{"id":"18832","subject":"[PATCH v2 2/2] Save init/clone --ignore-paths option as svn-remotes.svn.ignore-paths","startedAt":"2009-04-11T17:46:17Z","lastAt":"2009-04-12T08:29:14Z","messageCount":4,"participants":["Ben Jackson","Eric Wong","Junio C Hamano"],"isPatch":true,"patchVersion":2,"patchTotal":2},"messages":[{"id":"111054","messageId":"1239471978-45479-1-git-send-email-ben@ben.com","threadId":"18832","inReplyTo":null,"subject":"[PATCH v2 1/2] Add per-svn-remote ignore-paths config","fromName":"Ben Jackson","fromEmail":"ben@ben.com","sentAt":"2009-04-11T17:46:17Z","receivedAt":"2009-04-11T17:46:17Z","isPatch":true,"sender":{"key":"ben@ben.com","avatar":"https://gravatar.com/avatar/df49904dd23b03a5f57d9d53c0bf9fb6f69a14fac075c98f54f26cf1ce960794?d=mp&s=160"},"body":"The --ignore-paths option to fetch is very useful for working on a subset\nof a SVN repository.  For proper operation, every command that causes a\nfetch (explicit or implied) must include a matching --ignore-paths option.\n\nThis patch adds a persistent svn-remote.$repo_id.ignore-paths config by\npromoting Fetcher::is_path_ignored to a member function and initializing\n$self->{ignore_regex} in Fetcher::new.  Command line --ignore-paths is\nstill recognized and acts in addition to the config value.\n\nSigned-off-by: Ben Jackson <ben@ben.com>\n---\n\nThis version fixes a bug found by Eric Wong (inappropriate cut'n'paste\nuse of perl m//o) and extends the test cases to include independent\ntests for command-line and config ignore-paths.\n\n Documentation/git-svn.txt       |   22 ++++++++++-----\n git-svn.perl                    |   26 ++++++++++--------\n t/t9134-git-svn-ignore-paths.sh |   55 ++++++++++++++++++++++++++++++++++++--\n 3 files changed, 82 insertions(+), 21 deletions(-)\n\ndiff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt\nindex b7b1af8..af2d6c2 100644\n--- a/Documentation/git-svn.txt\n+++ b/Documentation/git-svn.txt\n@@ -104,17 +104,25 @@ repository, either don't use this option or you should both use it in\n the same local timezone.\n \n --ignore-paths=<regex>;;\n-\tThis allows one to specify Perl regular expression that will\n+\tThis allows one to specify a Perl regular expression that will\n \tcause skipping of all matching paths from checkout from SVN.\n-\tExamples:\n+\tThe '--ignore-paths' option should match for every 'fetch'\n+\t(including automatic fetches due to 'clone', 'dcommit',\n+\t'rebase', etc) on a given repository.\n \n-\t--ignore-paths=\"^doc\" - skip \"doc*\" directory for every fetch.\n+config key: svn-remote.<name>.ignore-paths\n \n-\t--ignore-paths=\"^[^/]+/(?:branches|tags)\" - skip \"branches\"\n-\t    and \"tags\" of first level directories.\n+\tIf the ignore-paths config key is set and the command\n+\tline option is also given, both regular expressions\n+\twill be used.\n \n-\tRegular expression is not persistent, you should specify\n-\tit every time when fetching.\n+Examples:\n+\n+\t--ignore-paths=\"^doc\" - skip \"doc*\" directory for every\n+\t    fetch.\n+\n+\t--ignore-paths=\"^[^/]+/(?:branches|tags)\" - skip\n+\t    \"branches\" and \"tags\" of first level directories.\n \n 'clone'::\n \tRuns 'init' and 'fetch'.  It will automatically create a\ndiff --git a/git-svn.perl b/git-svn.perl\nindex d919798..8e195ed 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -3286,6 +3286,8 @@ sub new {\n \t\t$self->{empty_symlinks} =\n \t\t                  _mark_empty_symlinks($git_svn, $switch_path);\n \t}\n+\t$self->{ignore_regex} = eval { command_oneline('config', '--get',\n+\t\t\t     \"svn-remote.$git_svn->{repo_id}.ignore-paths\") };\n \t$self->{empty} = {};\n \t$self->{dir_prop} = {};\n \t$self->{file_prop} = {};\n@@ -3350,8 +3352,10 @@ sub in_dot_git {\n \n # return value: 0 -- don't ignore, 1 -- ignore\n sub is_path_ignored {\n-\tmy ($path) = @_;\n+\tmy ($self, $path) = @_;\n \treturn 1 if in_dot_git($path);\n+\treturn 1 if defined($self->{ignore_regex}) &&\n+\t            $path =~ m!$self->{ignore_regex}!;\n \treturn 0 unless defined($_ignore_regex);\n \treturn 1 if $path =~ m!$_ignore_regex!o;\n \treturn 0;\n@@ -3382,7 +3386,7 @@ sub git_path {\n \n sub delete_entry {\n \tmy ($self, $path, $rev, $pb) = @_;\n-\treturn undef if is_path_ignored($path);\n+\treturn undef if $self->is_path_ignored($path);\n \n \tmy $gpath = $self->git_path($path);\n \treturn undef if ($gpath eq '');\n@@ -3415,7 +3419,7 @@ sub open_file {\n \tmy ($self, $path, $pb, $rev) = @_;\n \tmy ($mode, $blob);\n \n-\tgoto out if is_path_ignored($path);\n+\tgoto out if $self->is_path_ignored($path);\n \n \tmy $gpath = $self->git_path($path);\n \t($mode, $blob) = (command('ls-tree', '-z', $self->{c}, \"./$gpath\")\n@@ -3435,7 +3439,7 @@ sub add_file {\n \tmy ($self, $path, $pb, $cp_path, $cp_rev) = @_;\n \tmy $mode;\n \n-\tif (!is_path_ignored($path)) {\n+\tif (!$self->is_path_ignored($path)) {\n \t\tmy ($dir, $file) = ($path =~ m#^(.*?)/?([^/]+)$#);\n \t\tdelete $self->{empty}->{$dir};\n \t\t$mode = '100644';\n@@ -3446,7 +3450,7 @@ sub add_file {\n \n sub add_directory {\n \tmy ($self, $path, $cp_path, $cp_rev) = @_;\n-\tgoto out if is_path_ignored($path);\n+\tgoto out if $self->is_path_ignored($path);\n \tmy $gpath = $self->git_path($path);\n \tif ($gpath eq '') {\n \t\tmy ($ls, $ctx) = command_output_pipe(qw/ls-tree\n@@ -3470,7 +3474,7 @@ out:\n \n sub change_dir_prop {\n \tmy ($self, $db, $prop, $value) = @_;\n-\treturn undef if is_path_ignored($db->{path});\n+\treturn undef if $self->is_path_ignored($db->{path});\n \t$self->{dir_prop}->{$db->{path}} ||= {};\n \t$self->{dir_prop}->{$db->{path}}->{$prop} = $value;\n \tundef;\n@@ -3478,7 +3482,7 @@ sub change_dir_prop {\n \n sub absent_directory {\n \tmy ($self, $path, $pb) = @_;\n-\treturn undef if is_path_ignored($path);\n+\treturn undef if $self->is_path_ignored($path);\n \t$self->{absent_dir}->{$pb->{path}} ||= [];\n \tpush @{$self->{absent_dir}->{$pb->{path}}}, $path;\n \tundef;\n@@ -3486,7 +3490,7 @@ sub absent_directory {\n \n sub absent_file {\n \tmy ($self, $path, $pb) = @_;\n-\treturn undef if is_path_ignored($path);\n+\treturn undef if $self->is_path_ignored($path);\n \t$self->{absent_file}->{$pb->{path}} ||= [];\n \tpush @{$self->{absent_file}->{$pb->{path}}}, $path;\n \tundef;\n@@ -3494,7 +3498,7 @@ sub absent_file {\n \n sub change_file_prop {\n \tmy ($self, $fb, $prop, $value) = @_;\n-\treturn undef if is_path_ignored($fb->{path});\n+\treturn undef if $self->is_path_ignored($fb->{path});\n \tif ($prop eq 'svn:executable') {\n \t\tif ($fb->{mode_b} != 120000) {\n \t\t\t$fb->{mode_b} = defined $value ? 100755 : 100644;\n@@ -3510,7 +3514,7 @@ sub change_file_prop {\n \n sub apply_textdelta {\n \tmy ($self, $fb, $exp) = @_;\n-\treturn undef if is_path_ignored($fb->{path});\n+\treturn undef if $self->is_path_ignored($fb->{path});\n \tmy $fh = $::_repository->temp_acquire('svn_delta');\n \t# $fh gets auto-closed() by SVN::TxDelta::apply(),\n \t# (but $base does not,) so dup() it for reading in close_file\n@@ -3557,7 +3561,7 @@ sub apply_textdelta {\n \n sub close_file {\n \tmy ($self, $fb, $exp) = @_;\n-\treturn undef if is_path_ignored($fb->{path});\n+\treturn undef if $self->is_path_ignored($fb->{path});\n \n \tmy $hash;\n \tmy $path = $self->git_path($fb->{path});\ndiff --git a/t/t9134-git-svn-ignore-paths.sh b/t/t9134-git-svn-ignore-paths.sh\nindex c4b5b8b..b9a1597 100755\n--- a/t/t9134-git-svn-ignore-paths.sh\n+++ b/t/t9134-git-svn-ignore-paths.sh\n@@ -31,6 +31,22 @@ test_expect_success 'clone an SVN repository with ignored www directory' '\n \ttest_cmp expect expect2\n '\n \n+test_expect_success 'init+fetch an SVN repository with ignored www directory' '\n+\tgit svn init \"$svnrepo\" c &&\n+\t( cd c && git svn fetch --ignore-paths=\"^www\" ) &&\n+\trm expect2 &&\n+\techo test_qqq > expect &&\n+\tfor i in c/*/*.txt; do cat $i >> expect2; done &&\n+\ttest_cmp expect expect2\n+'\n+\n+test_expect_success 'set persistent ignore-paths config' '\n+\t(\n+\t    cd g &&\n+\t    git config svn-remote.svn.ignore-paths \"^www\"\n+\t)\n+'\n+\n test_expect_success 'SVN-side change outside of www' '\n \t(\n \t\tcd s &&\n@@ -41,9 +57,20 @@ test_expect_success 'SVN-side change outside of www' '\n \t)\n '\n \n-test_expect_success 'update git svn-cloned repo' '\n+test_expect_success 'update git svn-cloned repo (config ignore)' '\n \t(\n \t\tcd g &&\n+\t\tgit svn rebase &&\n+\t\tprintf \"test_qqq\\nb\\n\" > expect &&\n+\t\tfor i in */*.txt; do cat $i >> expect2; done &&\n+\t\ttest_cmp expect2 expect &&\n+\t\trm expect expect2\n+\t)\n+'\n+\n+test_expect_success 'update git svn-cloned repo (option ignore)' '\n+\t(\n+\t\tcd c &&\n \t\tgit svn rebase --ignore-paths=\"^www\" &&\n \t\tprintf \"test_qqq\\nb\\n\" > expect &&\n \t\tfor i in */*.txt; do cat $i >> expect2; done &&\n@@ -62,9 +89,20 @@ test_expect_success 'SVN-side change inside of ignored www' '\n \t)\n '\n \n-test_expect_success 'update git svn-cloned repo' '\n+test_expect_success 'update git svn-cloned repo (config ignore)' '\n \t(\n \t\tcd g &&\n+\t\tgit svn rebase &&\n+\t\tprintf \"test_qqq\\nb\\n\" > expect &&\n+\t\tfor i in */*.txt; do cat $i >> expect2; done &&\n+\t\ttest_cmp expect2 expect &&\n+\t\trm expect expect2\n+\t)\n+'\n+\n+test_expect_success 'update git svn-cloned repo (option ignore)' '\n+\t(\n+\t\tcd c &&\n \t\tgit svn rebase --ignore-paths=\"^www\" &&\n \t\tprintf \"test_qqq\\nb\\n\" > expect &&\n \t\tfor i in */*.txt; do cat $i >> expect2; done &&\n@@ -84,9 +122,20 @@ test_expect_success 'SVN-side change in and out of ignored www' '\n \t)\n '\n \n-test_expect_success 'update git svn-cloned repo again' '\n+test_expect_success 'update git svn-cloned repo again (config ignore)' '\n \t(\n \t\tcd g &&\n+\t\tgit svn rebase &&\n+\t\tprintf \"test_qqq\\nb\\nygg\\n\" > expect &&\n+\t\tfor i in */*.txt; do cat $i >> expect2; done &&\n+\t\ttest_cmp expect2 expect &&\n+\t\trm expect expect2\n+\t)\n+'\n+\n+test_expect_success 'update git svn-cloned repo again (option ignore)' '\n+\t(\n+\t\tcd c &&\n \t\tgit svn rebase --ignore-paths=\"^www\" &&\n \t\tprintf \"test_qqq\\nb\\nygg\\n\" > expect &&\n \t\tfor i in */*.txt; do cat $i >> expect2; done &&\n-- \n1.6.2.2.487.gd6486\n"},{"id":"111053","messageId":"1239471978-45479-2-git-send-email-ben@ben.com","threadId":"18832","inReplyTo":"1239471978-45479-1-git-send-email-ben@ben.com","subject":"[PATCH v2 2/2] Save init/clone --ignore-paths option as svn-remotes.svn.ignore-paths","fromName":"Ben Jackson","fromEmail":"ben@ben.com","sentAt":"2009-04-11T17:46:18Z","receivedAt":"2009-04-11T17:46:18Z","isPatch":true,"sender":{"key":"ben@ben.com","avatar":"https://gravatar.com/avatar/df49904dd23b03a5f57d9d53c0bf9fb6f69a14fac075c98f54f26cf1ce960794?d=mp&s=160"},"body":"Signed-off-by: Ben Jackson <ben@ben.com>\n---\n Documentation/git-svn.txt       |    4 ++++\n git-svn.perl                    |    3 +++\n t/t9134-git-svn-ignore-paths.sh |    4 ++--\n 3 files changed, 9 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt\nindex af2d6c2..cd47bff 100644\n--- a/Documentation/git-svn.txt\n+++ b/Documentation/git-svn.txt\n@@ -85,6 +85,10 @@ COMMANDS\n \tspecified, the prefix must include a trailing slash.\n \tSetting a prefix is useful if you wish to track multiple\n \tprojects that share a common repository.\n+--ignore-paths=<regex>;;\n+\tWhen passed to 'init' or 'clone' this regular expression will\n+\tbe preserved as a config key.  See 'fetch' for a description\n+\tof '--ignore-paths'.\n \n 'fetch'::\n \tFetch unfetched revisions from the Subversion remote we are\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 8e195ed..a04d158 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -334,6 +334,9 @@ sub do_git_init_db {\n \t\tcommand_noisy('config', \"$pfx.$i\", $icv{$i});\n \t\t$set = $i;\n \t}\n+\tmy $ignore_regex = \\$SVN::Git::Fetcher::_ignore_regex;\n+\tcommand_noisy('config', \"$pfx.ignore-paths\", $$ignore_regex)\n+\t\tif defined $$ignore_regex;\n }\n \n sub init_subdir {\ndiff --git a/t/t9134-git-svn-ignore-paths.sh b/t/t9134-git-svn-ignore-paths.sh\nindex b9a1597..71fdc4a 100755\n--- a/t/t9134-git-svn-ignore-paths.sh\n+++ b/t/t9134-git-svn-ignore-paths.sh\n@@ -40,10 +40,10 @@ test_expect_success 'init+fetch an SVN repository with ignored www directory' '\n \ttest_cmp expect expect2\n '\n \n-test_expect_success 'set persistent ignore-paths config' '\n+test_expect_success 'verify ignore-paths config saved by clone' '\n \t(\n \t    cd g &&\n-\t    git config svn-remote.svn.ignore-paths \"^www\"\n+\t    git config --get svn-remote.svn.ignore-paths | fgrep \"www\"\n \t)\n '\n \n-- \n1.6.2.2.487.gd6486\n"},{"id":"111109","messageId":"20090412005901.GB10656@dcvr.yhbt.net","threadId":"18832","inReplyTo":"1239471978-45479-1-git-send-email-ben@ben.com","subject":"Re: [PATCH v2 1/2] Add per-svn-remote ignore-paths config","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2009-04-12T00:59:01Z","receivedAt":"2009-04-12T00:59:01Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Ben Jackson <ben@ben.com> wrote:\n> Signed-off-by: Ben Jackson <ben@ben.com>\n> \n> ---\n> \n> This version fixes a bug found by Eric Wong (inappropriate cut'n'paste\n> use of perl m//o) and extends the test cases to include independent\n> tests for command-line and config ignore-paths.\n\nThanks Ben, this series acked and pushed out to\ngit://git.bogomips.org/git-svn.git\n\n-- \nEric Wong\n"},{"id":"111122","messageId":"7vskke9sx1.fsf@gitster.siamese.dyndns.org","threadId":"18832","inReplyTo":"20090412005901.GB10656@dcvr.yhbt.net","subject":"Re: [PATCH v2 1/2] Add per-svn-remote ignore-paths config","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-04-12T08:29:14Z","receivedAt":"2009-04-12T08:29:14Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Eric Wong <normalperson@yhbt.net> writes:\n\n> Ben Jackson <ben@ben.com> wrote:\n>> Signed-off-by: Ben Jackson <ben@ben.com>\n>> \n>> ---\n>> \n>> This version fixes a bug found by Eric Wong (inappropriate cut'n'paste\n>> use of perl m//o) and extends the test cases to include independent\n>> tests for command-line and config ignore-paths.\n>\n> Thanks Ben, this series acked and pushed out to\n> git://git.bogomips.org/git-svn.git\n\nThanks, pulled.\n"}]}