{"thread":{"id":"33595","subject":"Re: Fwd: [PATCH] git-svn: added an --include-path flag","startedAt":"2013-04-24T21:28:56Z","lastAt":"2013-05-09T01:19:04Z","messageCount":5,"participants":["Eric Wong","Paul Walmsley"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"215389","messageId":"20130424212856.GA23696@dcvr.yhbt.net","threadId":"33595","inReplyTo":"CAHpQJx0iT_+pOzdEJ-uyn7GjkXs8ZwhfPoMYpQDxwAB5mQ1xrw@mail.gmail.com","subject":"Re: Fwd: [PATCH] git-svn: added an --include-path flag","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2013-04-24T21:28:56Z","receivedAt":"2013-04-24T21:28:56Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Paul Walmsley <pjwhams@gmail.com> wrote:\n> Hi,\n> Please forgive the direct approach, but I submitted a git-svn patch to the\n> git list which sank without any comment. As major contributors to git-svn I\n> would like to solicit your feedback on it. The patch is so that git svn\n> clone supports '--include-path' as a complement to '--ignore-path'.  I had\n> a need for this as our SVN repository has many top level folders of which\n> only a few may be needed for any project.  I wanted to contribute the patch\n> back as I think it may be useful to others. I've included unit tests too.\n\nNo forgivness necessary, it's standard practice to Cc maintainers in git\n(and Linux kernel) patch submissions :)\n\n(Re-adding git ML-as Cc)\n\n> --- /dev/null\n> +++ b/t/t9147-git-svn-include-paths.sh\n> @@ -0,0 +1,150 @@\n> +#!/bin/sh\n> +#\n> +# Copyright (c) 2009 Vitaly Shukela\n> +# Copyright (c) 2009 Eric Wong\n\nUse your name (and current year) in copyright headers for your\nsubmissions.\n\n\nI'll take a closer look at the rest of the patch later, but your patch\nbelow appears line-wrapped and mangled (see\nDocumentation/SubmittingPatches).\n\nAlso, we'd greatly appreciate you omit HTML from emails in the future.\n\nThanks.\n"},{"id":"215393","messageId":"1366842790-18877-1-git-send-email-pjwhams@gmail.com","threadId":"33595","inReplyTo":"20130424212856.GA23696@dcvr.yhbt.net","subject":"[PATCH] git-svn: added an --include-path flag (resent fixing mail format)","fromName":"Paul Walmsley","fromEmail":"pjwhams@gmail.com","sentAt":"2013-04-24T22:33:10Z","receivedAt":"2013-04-24T22:33:10Z","isPatch":true,"sender":{"key":"pjwhams@gmail.com","avatar":null},"body":"The SVN::Fetcher module is now able to filter for inclusion as well\nas exclusion (as used by --ignore-path). Also added tests, documentation\nchanges and git completion script.\n\nIf you have an SVN repository with many top level directories and you\nonly want a git-svn clone of some of them then using --ignore-path is\ndifficult as it requires a very long regexp. In this case it's much\neasier to filter for inclusion.\n---\n Documentation/git-svn.txt              |   12 +++\n contrib/completion/git-completion.bash |    2 +-\n git-svn.perl                           |    4 +\n perl/Git/SVN/Fetcher.pm                |   13 ++-\n t/t9147-git-svn-include-paths.sh       |  150 ++++++++++++++++++++++++++++++++\n 5 files changed, 179 insertions(+), 2 deletions(-)\n create mode 100755 t/t9147-git-svn-include-paths.sh\n\ndiff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt\nindex 69decb1..df1f40c 100644\n--- a/Documentation/git-svn.txt\n+++ b/Documentation/git-svn.txt\n@@ -85,6 +85,10 @@ COMMANDS\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+--include-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 '--include-paths'.\n --no-minimize-url;;\n \tWhen tracking multiple directories (using --stdlayout,\n \t--branches, or --tags options), git svn will attempt to connect\n@@ -146,6 +150,14 @@ Skip \"branches\" and \"tags\" of first level directories;;\n ------------------------------------------------------------------------\n --\n \n+--include-paths=<regex>;;\n+\tThis allows one to specify a Perl regular expression that will\n+\tcause the inclusion of only matching paths from checkout from SVN.\n+\tThe '--include-paths' option should match for every 'fetch'\n+\t(including automatic fetches due to 'clone', 'dcommit',\n+\t'rebase', etc) on a given repository. '--ignore-paths' takes \n+\tprecedence over '--include-paths'.\n+\n --log-window-size=<n>;;\n     Fetch <n> log entries per request when scanning Subversion history.\n     The default is 100. For very large Subversion repositories, larger\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 39c7ff8..8b75d01 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2222,7 +2222,7 @@ _git_svn ()\n \t\t\t--no-metadata --use-svm-props --use-svnsync-props\n \t\t\t--log-window-size= --no-checkout --quiet\n \t\t\t--repack-flags --use-log-author --localtime\n-\t\t\t--ignore-paths= $remote_opts\n+\t\t\t--ignore-paths= --include-paths= $remote_opts\n \t\t\t\"\n \t\tlocal init_opts=\"\n \t\t\t--template= --shared= --trunk= --tags=\ndiff --git a/git-svn.perl b/git-svn.perl\nindex bd5266c..6d713e1 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -127,6 +127,7 @@ my %remote_opts = ( 'username=s' => \\$Git::SVN::Prompt::_username,\n                     'config-dir=s' => \\$Git::SVN::Ra::config_dir,\n                     'no-auth-cache' => \\$Git::SVN::Prompt::_no_auth_cache,\n                     'ignore-paths=s' => \\$Git::SVN::Fetcher::_ignore_regex,\n+                    'include-paths=s' => \\$Git::SVN::Fetcher::_include_regex,\n                     'ignore-refs=s' => \\$Git::SVN::Ra::_ignore_refs_regex );\n my %fc_opts = ( 'follow-parent|follow!' => \\$Git::SVN::_follow_parent,\n \t\t'authors-file|A=s' => \\$_authors,\n@@ -477,6 +478,9 @@ sub do_git_init_db {\n \tmy $ignore_paths_regex = \\$Git::SVN::Fetcher::_ignore_regex;\n \tcommand_noisy('config', \"$pfx.ignore-paths\", $$ignore_paths_regex)\n \t\tif defined $$ignore_paths_regex;\n+\tmy $include_paths_regex = \\$Git::SVN::Fetcher::_include_regex;\n+\tcommand_noisy('config', \"$pfx.include-paths\", $$include_paths_regex)\n+\t\tif defined $$include_paths_regex;\n \tmy $ignore_refs_regex = \\$Git::SVN::Ra::_ignore_refs_regex;\n \tcommand_noisy('config', \"$pfx.ignore-refs\", $$ignore_refs_regex)\n \t\tif defined $$ignore_refs_regex;\ndiff --git a/perl/Git/SVN/Fetcher.pm b/perl/Git/SVN/Fetcher.pm\nindex 046a7a2..27824e7 100644\n--- a/perl/Git/SVN/Fetcher.pm\n+++ b/perl/Git/SVN/Fetcher.pm\n@@ -1,5 +1,5 @@\n package Git::SVN::Fetcher;\n-use vars qw/@ISA $_ignore_regex $_preserve_empty_dirs $_placeholder_filename\n+use vars qw/@ISA $_ignore_regex $_include_regex $_preserve_empty_dirs $_placeholder_filename\n             @deleted_gpath %added_placeholder $repo_id/;\n use strict;\n use warnings;\n@@ -33,6 +33,10 @@ sub new {\n \tmy $v = eval { command_oneline('config', '--get', $k) };\n \t$self->{ignore_regex} = $v;\n \n+\t$k = \"svn-remote.$repo_id.include-paths\";\n+\t$v = eval { command_oneline('config', '--get', $k) };\n+\t$self->{include_regex} = $v;\n+\n \t$k = \"svn-remote.$repo_id.preserve-empty-dirs\";\n \t$v = eval { command_oneline('config', '--get', '--bool', $k) };\n \tif ($v && $v eq 'true') {\n@@ -117,11 +121,18 @@ sub in_dot_git {\n }\n \n # return value: 0 -- don't ignore, 1 -- ignore\n+# This will also check whether the path is explicitly included\n sub is_path_ignored {\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 if defined($self->{include_regex}) &&\n+\t            $path =~ m!$self->{include_regex}!;\n+\treturn 0 if defined($_include_regex) &&\n+\t            $path =~ m!$_include_regex!;\n+\treturn 1 if defined($self->{include_regex});\n+\treturn 1 if defined($_include_regex);\n \treturn 0 unless defined($_ignore_regex);\n \treturn 1 if $path =~ m!$_ignore_regex!o;\n \treturn 0;\ndiff --git a/t/t9147-git-svn-include-paths.sh b/t/t9147-git-svn-include-paths.sh\nnew file mode 100755\nindex 0000000..e2e9812\n--- /dev/null\n+++ b/t/t9147-git-svn-include-paths.sh\n@@ -0,0 +1,150 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2009 Vitaly Shukela\n+# Copyright (c) 2009 Eric Wong\n+#\n+\n+test_description='git svn property tests'\n+. ./lib-git-svn.sh\n+\n+test_expect_success 'setup test repository' '\n+\tsvn_cmd co \"$svnrepo\" s &&\n+\t(\n+\t\tcd s &&\n+\t\tmkdir qqq www xxx &&\n+\t\techo test_qqq > qqq/test_qqq.txt &&\n+\t\techo test_www > www/test_www.txt &&\n+\t\techo test_xxx > xxx/test_xxx.txt &&\n+\t\tsvn_cmd add qqq &&\n+\t\tsvn_cmd add www &&\n+\t\tsvn_cmd add xxx &&\n+\t\tsvn_cmd commit -m \"create some files\" &&\n+\t\tsvn_cmd up &&\n+\t\techo hi >> www/test_www.txt &&\n+\t\tsvn_cmd commit -m \"modify www/test_www.txt\" &&\n+\t\tsvn_cmd up\n+\t)\n+'\n+\n+test_expect_success 'clone an SVN repository with filter to include qqq directory' '\n+\tgit svn clone --include-paths=\"qqq\" \"$svnrepo\" g &&\n+\techo test_qqq > expect &&\n+\tfor i in g/*/*.txt; do cat $i >> expect2; done &&\n+\ttest_cmp expect expect2\n+'\n+\n+\n+test_expect_success 'init+fetch an SVN repository with included qqq directory' '\n+\tgit svn init \"$svnrepo\" c &&\n+ \t( cd c && git svn fetch --include-paths=\"qqq\" ) &&\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 'verify include-paths config saved by clone' '\n+\t(\n+\t    cd g &&\n+\t    git config --get svn-remote.svn.include-paths | fgrep \"qqq\"\n+\t)\n+'\n+\n+test_expect_success 'SVN-side change outside of www' '\n+\t(\n+\t\tcd s &&\n+\t\techo b >> qqq/test_qqq.txt &&\n+\t\tsvn_cmd commit -m \"SVN-side change outside of www\" &&\n+\t\tsvn_cmd up &&\n+\t\tsvn_cmd log -v | fgrep \"SVN-side change outside of www\"\n+\t)\n+'\n+\n+test_expect_success 'update git svn-cloned repo (config include)' '\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 include)' '\n+\t(\n+\t\tcd c &&\n+\t\tgit svn rebase --include-paths=\"qqq\" &&\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 'SVN-side change inside of ignored www' '\n+\t(\n+\t\tcd s &&\n+\t\techo zaq >> www/test_www.txt\n+\t\tsvn_cmd commit -m \"SVN-side change inside of www/test_www.txt\" &&\n+\t\tsvn_cmd up &&\n+\t\tsvn_cmd log -v | fgrep \"SVN-side change inside of www/test_www.txt\"\n+\t)\n+'\n+\n+test_expect_success 'update git svn-cloned repo (config include)' '\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 include)' '\n+\t(\n+\t\tcd c &&\n+\t\tgit svn rebase --include-paths=\"qqq\" &&\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 'SVN-side change in and out of included qqq' '\n+\t(\n+\t\tcd s &&\n+\t\techo cvf >> www/test_www.txt\n+\t\techo ygg >> qqq/test_qqq.txt\n+\t\tsvn_cmd commit -m \"SVN-side change in and out of ignored www\" &&\n+\t\tsvn_cmd up &&\n+\t\tsvn_cmd log -v | fgrep \"SVN-side change in and out of ignored www\"\n+\t)\n+'\n+\n+test_expect_success 'update git svn-cloned repo again (config include)' '\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 include)' '\n+\t(\n+\t\tcd c &&\n+\t\tgit svn rebase --include-paths=\"qqq\" &&\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_done\n-- \n1.7.10.4\n"},{"id":"216193","messageId":"20130501204616.GA12203@dcvr.yhbt.net","threadId":"33595","inReplyTo":"1366842790-18877-1-git-send-email-pjwhams@gmail.com","subject":"Re: [PATCH] git-svn: added an --include-path flag (resent fixing mail format)","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2013-05-01T20:46:16Z","receivedAt":"2013-05-01T20:46:16Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Paul Walmsley <pjwhams@gmail.com> wrote:\n> The SVN::Fetcher module is now able to filter for inclusion as well\n> as exclusion (as used by --ignore-path). Also added tests, documentation\n> changes and git completion script.\n> \n> If you have an SVN repository with many top level directories and you\n> only want a git-svn clone of some of them then using --ignore-path is\n> difficult as it requires a very long regexp. In this case it's much\n> easier to filter for inclusion.\n\nThanks, comments inline.\n\nA Signed-off-by is necessary (especially for new contributors)\n\n(not _my_ policy, but project policy, see Documentation/SubmittingPatches)\n\n> @@ -1,5 +1,5 @@\n>  package Git::SVN::Fetcher;\n> -use vars qw/@ISA $_ignore_regex $_preserve_empty_dirs $_placeholder_filename\n> +use vars qw/@ISA $_ignore_regex $_include_regex $_preserve_empty_dirs $_placeholder_filename\n>              @deleted_gpath %added_placeholder $repo_id/;\n\nPlease wrap long lines at 80 columns.\n\n> --- /dev/null\n> +++ b/t/t9147-git-svn-include-paths.sh\n> @@ -0,0 +1,150 @@\n> +#!/bin/sh\n> +#\n> +# Copyright (c) 2009 Vitaly Shukela\n> +# Copyright (c) 2009 Eric Wong\n> +#\n\nI already commented on this in the previous email, please add your\nown copyright header (you can add a note saying this is based on\nt9134 by Vitaly).\n\nThanks again.\n"},{"id":"216378","messageId":"1367622618-28220-1-git-send-email-pjwhams@gmail.com","threadId":"33595","inReplyTo":"20130501204616.GA12203@dcvr.yhbt.net","subject":"[PATCH] git-svn: added an --include-path flag","fromName":"Paul Walmsley","fromEmail":"pjwhams@gmail.com","sentAt":"2013-05-03T23:10:18Z","receivedAt":"2013-05-03T23:10:18Z","isPatch":true,"sender":{"key":"pjwhams@gmail.com","avatar":null},"body":"The SVN::Fetcher module is now able to filter for inclusion as well\nas exclusion (as used by --ignore-path). Also added tests, documentation\nchanges and git completion script.\n\nIf you have an SVN repository with many top level directories and you\nonly want a git-svn clone of some of them then using --ignore-path is\ndifficult as it requires a very long regexp. In this case it's much\neasier to filter for inclusion.\n\nSigned-off-by: Paul Walmsley <pjwhams@gmail.com>\n---\n Documentation/git-svn.txt              |   12 +++\n contrib/completion/git-completion.bash |    2 +-\n git-svn.perl                           |    4 +\n perl/Git/SVN/Fetcher.pm                |   16 +++-\n t/t9147-git-svn-include-paths.sh       |  149 ++++++++++++++++++++++++++++++++\n 5 files changed, 180 insertions(+), 3 deletions(-)\n create mode 100755 t/t9147-git-svn-include-paths.sh\n\ndiff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt\nindex 1b8b649..698a6bb 100644\n--- a/Documentation/git-svn.txt\n+++ b/Documentation/git-svn.txt\n@@ -85,6 +85,10 @@ COMMANDS\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+--include-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 '--include-paths'.\n --no-minimize-url;;\n \tWhen tracking multiple directories (using --stdlayout,\n \t--branches, or --tags options), git svn will attempt to connect\n@@ -146,6 +150,14 @@ Skip \"branches\" and \"tags\" of first level directories;;\n ------------------------------------------------------------------------\n --\n \n+--include-paths=<regex>;;\n+\tThis allows one to specify a Perl regular expression that will\n+\tcause the inclusion of only matching paths from checkout from SVN.\n+\tThe '--include-paths' option should match for every 'fetch'\n+\t(including automatic fetches due to 'clone', 'dcommit',\n+\t'rebase', etc) on a given repository. '--ignore-paths' takes \n+\tprecedence over '--include-paths'.\n+\n --log-window-size=<n>;;\n     Fetch <n> log entries per request when scanning Subversion history.\n     The default is 100. For very large Subversion repositories, larger\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex 2ba1461..8427df2 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2451,7 +2451,7 @@ _git_svn ()\n \t\t\t--no-metadata --use-svm-props --use-svnsync-props\n \t\t\t--log-window-size= --no-checkout --quiet\n \t\t\t--repack-flags --use-log-author --localtime\n-\t\t\t--ignore-paths= $remote_opts\n+\t\t\t--ignore-paths= --include-paths= $remote_opts\n \t\t\t\"\n \t\tlocal init_opts=\"\n \t\t\t--template= --shared= --trunk= --tags=\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 6c7bd95..5e56dc7 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -126,6 +126,7 @@ my %remote_opts = ( 'username=s' => \\$Git::SVN::Prompt::_username,\n                     'config-dir=s' => \\$Git::SVN::Ra::config_dir,\n                     'no-auth-cache' => \\$Git::SVN::Prompt::_no_auth_cache,\n                     'ignore-paths=s' => \\$Git::SVN::Fetcher::_ignore_regex,\n+                    'include-paths=s' => \\$Git::SVN::Fetcher::_include_regex,\n                     'ignore-refs=s' => \\$Git::SVN::Ra::_ignore_refs_regex );\n my %fc_opts = ( 'follow-parent|follow!' => \\$Git::SVN::_follow_parent,\n \t\t'authors-file|A=s' => \\$_authors,\n@@ -470,6 +471,9 @@ sub do_git_init_db {\n \tmy $ignore_paths_regex = \\$Git::SVN::Fetcher::_ignore_regex;\n \tcommand_noisy('config', \"$pfx.ignore-paths\", $$ignore_paths_regex)\n \t\tif defined $$ignore_paths_regex;\n+\tmy $include_paths_regex = \\$Git::SVN::Fetcher::_include_regex;\n+\tcommand_noisy('config', \"$pfx.include-paths\", $$include_paths_regex)\n+\t\tif defined $$include_paths_regex;\n \tmy $ignore_refs_regex = \\$Git::SVN::Ra::_ignore_refs_regex;\n \tcommand_noisy('config', \"$pfx.ignore-refs\", $$ignore_refs_regex)\n \t\tif defined $$ignore_refs_regex;\ndiff --git a/perl/Git/SVN/Fetcher.pm b/perl/Git/SVN/Fetcher.pm\nindex 046a7a2..d25524c 100644\n--- a/perl/Git/SVN/Fetcher.pm\n+++ b/perl/Git/SVN/Fetcher.pm\n@@ -1,6 +1,7 @@\n package Git::SVN::Fetcher;\n-use vars qw/@ISA $_ignore_regex $_preserve_empty_dirs $_placeholder_filename\n-            @deleted_gpath %added_placeholder $repo_id/;\n+use vars qw/@ISA $_ignore_regex $_include_regex $_preserve_empty_dirs \n+            $_placeholder_filename @deleted_gpath %added_placeholder \n+            $repo_id/;\n use strict;\n use warnings;\n use SVN::Delta;\n@@ -33,6 +34,10 @@ sub new {\n \tmy $v = eval { command_oneline('config', '--get', $k) };\n \t$self->{ignore_regex} = $v;\n \n+\t$k = \"svn-remote.$repo_id.include-paths\";\n+\t$v = eval { command_oneline('config', '--get', $k) };\n+\t$self->{include_regex} = $v;\n+\n \t$k = \"svn-remote.$repo_id.preserve-empty-dirs\";\n \t$v = eval { command_oneline('config', '--get', '--bool', $k) };\n \tif ($v && $v eq 'true') {\n@@ -117,11 +122,18 @@ sub in_dot_git {\n }\n \n # return value: 0 -- don't ignore, 1 -- ignore\n+# This will also check whether the path is explicitly included\n sub is_path_ignored {\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 if defined($self->{include_regex}) &&\n+\t            $path =~ m!$self->{include_regex}!;\n+\treturn 0 if defined($_include_regex) &&\n+\t            $path =~ m!$_include_regex!;\n+\treturn 1 if defined($self->{include_regex});\n+\treturn 1 if defined($_include_regex);\n \treturn 0 unless defined($_ignore_regex);\n \treturn 1 if $path =~ m!$_ignore_regex!o;\n \treturn 0;\ndiff --git a/t/t9147-git-svn-include-paths.sh b/t/t9147-git-svn-include-paths.sh\nnew file mode 100755\nindex 0000000..6a7ce30\n--- /dev/null\n+++ b/t/t9147-git-svn-include-paths.sh\n@@ -0,0 +1,149 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2013 Paul Walmsley - based on t9134 by Vitaly Shukela\n+#\n+\n+test_description='git svn property tests'\n+. ./lib-git-svn.sh\n+\n+test_expect_success 'setup test repository' '\n+\tsvn_cmd co \"$svnrepo\" s &&\n+\t(\n+\t\tcd s &&\n+\t\tmkdir qqq www xxx &&\n+\t\techo test_qqq > qqq/test_qqq.txt &&\n+\t\techo test_www > www/test_www.txt &&\n+\t\techo test_xxx > xxx/test_xxx.txt &&\n+\t\tsvn_cmd add qqq &&\n+\t\tsvn_cmd add www &&\n+\t\tsvn_cmd add xxx &&\n+\t\tsvn_cmd commit -m \"create some files\" &&\n+\t\tsvn_cmd up &&\n+\t\techo hi >> www/test_www.txt &&\n+\t\tsvn_cmd commit -m \"modify www/test_www.txt\" &&\n+\t\tsvn_cmd up\n+\t)\n+'\n+\n+test_expect_success 'clone an SVN repository with filter to include qqq directory' '\n+\tgit svn clone --include-paths=\"qqq\" \"$svnrepo\" g &&\n+\techo test_qqq > expect &&\n+\tfor i in g/*/*.txt; do cat $i >> expect2; done &&\n+\ttest_cmp expect expect2\n+'\n+\n+\n+test_expect_success 'init+fetch an SVN repository with included qqq directory' '\n+\tgit svn init \"$svnrepo\" c &&\n+ \t( cd c && git svn fetch --include-paths=\"qqq\" ) &&\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 'verify include-paths config saved by clone' '\n+\t(\n+\t    cd g &&\n+\t    git config --get svn-remote.svn.include-paths | fgrep \"qqq\"\n+\t)\n+'\n+\n+test_expect_success 'SVN-side change outside of www' '\n+\t(\n+\t\tcd s &&\n+\t\techo b >> qqq/test_qqq.txt &&\n+\t\tsvn_cmd commit -m \"SVN-side change outside of www\" &&\n+\t\tsvn_cmd up &&\n+\t\tsvn_cmd log -v | fgrep \"SVN-side change outside of www\"\n+\t)\n+'\n+\n+test_expect_success 'update git svn-cloned repo (config include)' '\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 include)' '\n+\t(\n+\t\tcd c &&\n+\t\tgit svn rebase --include-paths=\"qqq\" &&\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 'SVN-side change inside of ignored www' '\n+\t(\n+\t\tcd s &&\n+\t\techo zaq >> www/test_www.txt\n+\t\tsvn_cmd commit -m \"SVN-side change inside of www/test_www.txt\" &&\n+\t\tsvn_cmd up &&\n+\t\tsvn_cmd log -v | fgrep \"SVN-side change inside of www/test_www.txt\"\n+\t)\n+'\n+\n+test_expect_success 'update git svn-cloned repo (config include)' '\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 include)' '\n+\t(\n+\t\tcd c &&\n+\t\tgit svn rebase --include-paths=\"qqq\" &&\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 'SVN-side change in and out of included qqq' '\n+\t(\n+\t\tcd s &&\n+\t\techo cvf >> www/test_www.txt\n+\t\techo ygg >> qqq/test_qqq.txt\n+\t\tsvn_cmd commit -m \"SVN-side change in and out of ignored www\" &&\n+\t\tsvn_cmd up &&\n+\t\tsvn_cmd log -v | fgrep \"SVN-side change in and out of ignored www\"\n+\t)\n+'\n+\n+test_expect_success 'update git svn-cloned repo again (config include)' '\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 include)' '\n+\t(\n+\t\tcd c &&\n+\t\tgit svn rebase --include-paths=\"qqq\" &&\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_done\n-- \n1.7.10.4\n"},{"id":"216738","messageId":"20130509011904.GA24257@dcvr.yhbt.net","threadId":"33595","inReplyTo":"1367622618-28220-1-git-send-email-pjwhams@gmail.com","subject":"Re: [PATCH] git-svn: added an --include-path flag","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2013-05-09T01:19:04Z","receivedAt":"2013-05-09T01:19:04Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Paul Walmsley <pjwhams@gmail.com> wrote:\n> The SVN::Fetcher module is now able to filter for inclusion as well\n> as exclusion (as used by --ignore-path). Also added tests, documentation\n> changes and git completion script.\n> \n> If you have an SVN repository with many top level directories and you\n> only want a git-svn clone of some of them then using --ignore-path is\n> difficult as it requires a very long regexp. In this case it's much\n> easier to filter for inclusion.\n> \n> Signed-off-by: Paul Walmsley <pjwhams@gmail.com>\n\nThanks, signed-off and applied, will push.\n"}]}