{"thread":{"id":"17351","subject":"[PATCH] git-svn: add --ignore-paths option for fetching","startedAt":"2009-01-25T06:27:22Z","lastAt":"2009-01-26T06:28:57Z","messageCount":7,"participants":["Vitaly \"_Vi\" Shukela","Thomas Rast","public_vi","Eric Wong","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"101819","messageId":"1232864842-8841-1-git-send-email-public_vi@tut.by","threadId":"17351","inReplyTo":null,"subject":"[PATCH] git-svn: add --ignore-paths option for fetching","fromName":"Vitaly \"_Vi\" Shukela","fromEmail":"public_vi@tut.by","sentAt":"2009-01-25T06:27:22Z","receivedAt":"2009-01-25T06:27:22Z","isPatch":true,"sender":{"key":"vi0oss@gmail.com","avatar":"https://avatars.githubusercontent.com/u/173219?v=4"},"body":"\nSigned-off-by: Vitaly \"_Vi\" Shukela <public_vi@tut.by>\n---\n Documentation/git-svn.txt |    4 ++++\n git-svn.perl              |   25 +++++++++++++++++++++++--\n 2 files changed, 27 insertions(+), 2 deletions(-)\n\ndiff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt\nindex 63d2f5e..4aeb88b 100644\n--- a/Documentation/git-svn.txt\n+++ b/Documentation/git-svn.txt\n@@ -96,6 +96,10 @@ COMMANDS\n \tStore Git commit times in the local timezone instead of UTC.  This\n \tmakes 'git-log' (even without --date=local) show the same times\n \tthat `svn log` would in the local timezone.\n+--ignore-paths=<regex>;;\n+\tThis allows one to specify regular expression that will\n+\tcause skipping of all matching paths from checkout from SVN.\n+\tExample: --ignore-paths='^doc'\n \n This doesn't interfere with interoperating with the Subversion\n repository you cloned from, but if you wish for your local Git\ndiff --git a/git-svn.perl b/git-svn.perl\nindex d4cb538..4909b23 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -70,7 +70,8 @@ my ($_stdin, $_help, $_edit,\n $Git::SVN::_follow_parent = 1;\n 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+                    'no-auth-cache' => \\$Git::SVN::Prompt::_no_auth_cache,\n+                    'ignore-paths=s' => \\$SVN::Git::Fetcher::ignoreRegex );\n my %fc_opts = ( 'follow-parent|follow!' => \\$Git::SVN::_follow_parent,\n \t\t'authors-file|A=s' => \\$_authors,\n \t\t'repack:i' => \\$Git::SVN::_repack,\n@@ -3245,6 +3246,15 @@ use warnings;\n use Carp qw/croak/;\n use File::Temp qw/tempfile/;\n use IO::File qw//;\n+use vars qw/ $ignoreRegex/;\n+\n+# 0 -- don't ignore, 1 -- ignore\n+sub isPathIgnored($) {\n+    return 0 unless defined($ignoreRegex);\n+    my $path = shift;\n+    return 1 if $path =~ m!^$ignoreRegex!o;\n+    return 0;\n+}\n \n # file baton members: path, mode_a, mode_b, pool, fh, blob, base\n sub new {\n@@ -3323,6 +3333,7 @@ sub git_path {\n sub delete_entry {\n \tmy ($self, $path, $rev, $pb) = @_;\n \treturn undef if in_dot_git($path);\n+\treturn undef if isPathIgnored($path);\n \n \tmy $gpath = $self->git_path($path);\n \treturn undef if ($gpath eq '');\n@@ -3353,6 +3364,7 @@ sub open_file {\n \tmy ($mode, $blob);\n \n \tgoto out if in_dot_git($path);\n+\tgoto out if isPathIgnored($path);\n \n \tmy $gpath = $self->git_path($path);\n \t($mode, $blob) = (command('ls-tree', $self->{c}, '--', $gpath)\n@@ -3372,11 +3384,14 @@ sub add_file {\n \tmy ($self, $path, $pb, $cp_path, $cp_rev) = @_;\n \tmy $mode;\n \n+\tgoto out if isPathIgnored($path);\n+\n \tif (!in_dot_git($path)) {\n \t\tmy ($dir, $file) = ($path =~ m#^(.*?)/?([^/]+)$#);\n \t\tdelete $self->{empty}->{$dir};\n \t\t$mode = '100644';\n \t}\n+out:\n \t{ path => $path, mode_a => $mode, mode_b => $mode,\n \t  pool => SVN::Pool->new, action => 'A' };\n }\n@@ -3384,6 +3399,7 @@ sub add_file {\n sub add_directory {\n \tmy ($self, $path, $cp_path, $cp_rev) = @_;\n \tgoto out if in_dot_git($path);\n+\tgoto out if isPathIgnored($path);\n \tmy $gpath = $self->git_path($path);\n \tif ($gpath eq '') {\n \t\tmy ($ls, $ctx) = command_output_pipe(qw/ls-tree\n@@ -3408,6 +3424,7 @@ out:\n sub change_dir_prop {\n \tmy ($self, $db, $prop, $value) = @_;\n \treturn undef if in_dot_git($db->{path});\n+\treturn undef if isPathIgnored($db->{path});\n \t$self->{dir_prop}->{$db->{path}} ||= {};\n \t$self->{dir_prop}->{$db->{path}}->{$prop} = $value;\n \tundef;\n@@ -3416,6 +3433,7 @@ sub change_dir_prop {\n sub absent_directory {\n \tmy ($self, $path, $pb) = @_;\n \treturn undef if in_dot_git($pb->{path});\n+\treturn undef if isPathIgnored($path);\n \t$self->{absent_dir}->{$pb->{path}} ||= [];\n \tpush @{$self->{absent_dir}->{$pb->{path}}}, $path;\n \tundef;\n@@ -3424,6 +3442,7 @@ sub absent_directory {\n sub absent_file {\n \tmy ($self, $path, $pb) = @_;\n \treturn undef if in_dot_git($pb->{path});\n+\treturn undef if isPathIgnored($path);\n \t$self->{absent_file}->{$pb->{path}} ||= [];\n \tpush @{$self->{absent_file}->{$pb->{path}}}, $path;\n \tundef;\n@@ -3432,6 +3451,7 @@ sub absent_file {\n sub change_file_prop {\n \tmy ($self, $fb, $prop, $value) = @_;\n \treturn undef if in_dot_git($fb->{path});\n+\treturn undef if isPathIgnored($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@@ -3448,6 +3468,7 @@ sub change_file_prop {\n sub apply_textdelta {\n \tmy ($self, $fb, $exp) = @_;\n \treturn undef if (in_dot_git($fb->{path}));\n+\treturn undef if isPathIgnored($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@@ -3495,7 +3516,7 @@ sub apply_textdelta {\n sub close_file {\n \tmy ($self, $fb, $exp) = @_;\n \treturn undef if (in_dot_git($fb->{path}));\n-\n+\treturn undef if isPathIgnored($fb->{path});\n \tmy $hash;\n \tmy $path = $self->git_path($fb->{path});\n \tif (my $fh = $fb->{fh}) {\n-- \n1.5.6.5\n"},{"id":"101836","messageId":"200901251521.15591.trast@student.ethz.ch","threadId":"17351","inReplyTo":"1232864842-8841-1-git-send-email-public_vi@tut.by","subject":"Re: [PATCH] git-svn: add --ignore-paths option for fetching","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2009-01-25T14:21:05Z","receivedAt":"2009-01-25T14:21:05Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Vitaly \"_Vi\" Shukela wrote:\n> \n> Signed-off-by: Vitaly \"_Vi\" Shukela <public_vi@tut.by>\n\nThis would be a good place to explain why this is useful, and (if\napplicable) why you chose to implement it the way you did.\n\n> --- a/Documentation/git-svn.txt\n> +++ b/Documentation/git-svn.txt\n> @@ -96,6 +96,10 @@ COMMANDS\n>  \tStore Git commit times in the local timezone instead of UTC.  This\n>  \tmakes 'git-log' (even without --date=local) show the same times\n>  \tthat `svn log` would in the local timezone.\n> +--ignore-paths=<regex>;;\n> +\tThis allows one to specify regular expression that will\n> +\tcause skipping of all matching paths from checkout from SVN.\n> +\tExample: --ignore-paths='^doc'\n>  \n>  This doesn't interfere with interoperating with the Subversion\n>  repository you cloned from, but if you wish for your local Git\n\nYou put the --ignore-paths explanation in the middle of the\n--localtime documentation (the last paragraph quoted still talks about\n--localtime).\n\n> @@ -3245,6 +3246,15 @@ use warnings;\n>  use Carp qw/croak/;\n>  use File::Temp qw/tempfile/;\n>  use IO::File qw//;\n> +use vars qw/ $ignoreRegex/;\n> +\n> +# 0 -- don't ignore, 1 -- ignore\n> +sub isPathIgnored($) {\n> +    return 0 unless defined($ignoreRegex);\n> +    my $path = shift;\n> +    return 1 if $path =~ m!^$ignoreRegex!o;\n> +    return 0;\n> +}\n\nThis is the first function in git-svn.perl using camelCase.  Consider\nsticking to the current style and spelling it is_path_ignored().\n\n> @@ -3372,11 +3384,14 @@ sub add_file {\n>  \tmy ($self, $path, $pb, $cp_path, $cp_rev) = @_;\n>  \tmy $mode;\n>  \n> +\tgoto out if isPathIgnored($path);\n> +\n>  \tif (!in_dot_git($path)) {\n>  \t\tmy ($dir, $file) = ($path =~ m#^(.*?)/?([^/]+)$#);\n>  \t\tdelete $self->{empty}->{$dir};\n>  \t\t$mode = '100644';\n>  \t}\n> +out:\n>  \t{ path => $path, mode_a => $mode, mode_b => $mode,\n>  \t  pool => SVN::Pool->new, action => 'A' };\n>  }\n\nYou broke the symmetry here, while all other hunks just add an\nequivalent check to the existing in_dot_git().\n\nHowever, the latter makes me wonder if it would be cleaner to move the\nin_dot_git() test to isPathIgnored (er, is_path_ignored) too?\n\n\nFWIW, I like the feature; it seems a good way to exclude subtrees with\nlarge blobs, and I know several SVN repos that have such a directory.\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"101840","messageId":"497C9354.5050902@tut.by","threadId":"17351","inReplyTo":"200901251521.15591.trast@student.ethz.ch","subject":"Re: [PATCH] git-svn: add --ignore-paths option for fetching","fromName":"public_vi","fromEmail":"public_vi@tut.by","sentAt":"2009-01-25T16:29:08Z","receivedAt":"2009-01-25T16:29:08Z","isPatch":true,"sender":{"key":"vi0oss@gmail.com","avatar":"https://avatars.githubusercontent.com/u/173219?v=4"},"body":"It is useful for me, but I think I can be useful for others too.\nMay be it's better to make in inclusive, i.e. \"--only-matching=<regex>\"?\n> This would be a good place to explain why this is useful, and (if\n> applicable) why you chose to implement it the way you did.\n>   \n\nOK, fixing them.\n> You put the --ignore-paths explanation in the middle of the\n> --localtime documentation (the last paragraph quoted still talks about\n> --localtime).\n>   \n> This is the first function in git-svn.perl using camelCase.  Consider\n> sticking to the current style and spelling it is_path_ignored().\n>\n> You broke the symmetry here, while all other hunks just add an\n> equivalent check to the existing in_dot_git().\n>\n> However, the latter makes me wonder if it would be cleaner to move the\n> in_dot_git() test to isPathIgnored (er, is_path_ignored) too?\n>   \n"},{"id":"101889","messageId":"20090125224238.GA31581@untitled","threadId":"17351","inReplyTo":"200901251521.15591.trast@student.ethz.ch","subject":"Re: [PATCH] git-svn: add --ignore-paths option for fetching","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2009-01-25T22:42:38Z","receivedAt":"2009-01-25T22:42:38Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Thomas Rast <trast@student.ethz.ch> wrote:\n> Vitaly \"_Vi\" Shukela wrote:\n> > \n> > Signed-off-by: Vitaly \"_Vi\" Shukela <public_vi@tut.by>\n> \n> This would be a good place to explain why this is useful, and (if\n> applicable) why you chose to implement it the way you did.\n> \n> > --- a/Documentation/git-svn.txt\n> > +++ b/Documentation/git-svn.txt\n> > @@ -96,6 +96,10 @@ COMMANDS\n> >  \tStore Git commit times in the local timezone instead of UTC.  This\n> >  \tmakes 'git-log' (even without --date=local) show the same times\n> >  \tthat `svn log` would in the local timezone.\n> > +--ignore-paths=<regex>;;\n> > +\tThis allows one to specify regular expression that will\n> > +\tcause skipping of all matching paths from checkout from SVN.\n> > +\tExample: --ignore-paths='^doc'\n> >  \n> >  This doesn't interfere with interoperating with the Subversion\n> >  repository you cloned from, but if you wish for your local Git\n> \n> You put the --ignore-paths explanation in the middle of the\n> --localtime documentation (the last paragraph quoted still talks about\n> --localtime).\n> \n> > @@ -3245,6 +3246,15 @@ use warnings;\n> >  use Carp qw/croak/;\n> >  use File::Temp qw/tempfile/;\n> >  use IO::File qw//;\n> > +use vars qw/ $ignoreRegex/;\n> > +\n> > +# 0 -- don't ignore, 1 -- ignore\n> > +sub isPathIgnored($) {\n> > +    return 0 unless defined($ignoreRegex);\n> > +    my $path = shift;\n> > +    return 1 if $path =~ m!^$ignoreRegex!o;\n> > +    return 0;\n> > +}\n> \n> This is the first function in git-svn.perl using camelCase.  Consider\n> sticking to the current style and spelling it is_path_ignored().\n\nAlso, indentation is always done with tabs in git-svn (and the vast\nmajority of git as well).\n\n> > @@ -3372,11 +3384,14 @@ sub add_file {\n> >  \tmy ($self, $path, $pb, $cp_path, $cp_rev) = @_;\n> >  \tmy $mode;\n> >  \n> > +\tgoto out if isPathIgnored($path);\n> > +\n> >  \tif (!in_dot_git($path)) {\n> >  \t\tmy ($dir, $file) = ($path =~ m#^(.*?)/?([^/]+)$#);\n> >  \t\tdelete $self->{empty}->{$dir};\n> >  \t\t$mode = '100644';\n> >  \t}\n> > +out:\n> >  \t{ path => $path, mode_a => $mode, mode_b => $mode,\n> >  \t  pool => SVN::Pool->new, action => 'A' };\n> >  }\n> \n> You broke the symmetry here, while all other hunks just add an\n> equivalent check to the existing in_dot_git().\n> \n> However, the latter makes me wonder if it would be cleaner to move the\n> in_dot_git() test to isPathIgnored (er, is_path_ignored) too?\n\nThanks for the review, Thomas.  I agree with all your suggestions.\n\nVitaly: thank you for the patch.  Can you also provide a testcase to\nensure this functionality doesn't break during refactorings?  Thanks.\n\n-- \nEric Wong\n"},{"id":"101891","messageId":"497CEC56.3020900@tut.by","threadId":"17351","inReplyTo":"20090125224238.GA31581@untitled","subject":"Re: [PATCH] git-svn: add --ignore-paths option for fetching","fromName":"public_vi","fromEmail":"public_vi@tut.by","sentAt":"2009-01-25T22:48:54Z","receivedAt":"2009-01-25T22:48:54Z","isPatch":true,"sender":{"key":"vi0oss@gmail.com","avatar":"https://avatars.githubusercontent.com/u/173219?v=4"},"body":"Eric Wong wrote:\n> Thomas Rast <trast@student.ethz.ch> wrote:\n>   \n>\n> Also, indentation is always done with tabs in git-svn (and the vast\n> majority of git as well).\n>\n>   \nWhitespace is invisible for me now, I only checked according to \nDocumentation/SubmittingPatches about extra lines adds or removes caused \njust by whitespace difference.\n>\n>\n> Vitaly: thank you for the patch.  Can you also provide a testcase to\n> ensure this functionality doesn't break during refactorings?  Thanks.\n>\n>   \nAlready done it with testcase. There are two new packs of patches sent \nto git@vger.kernel.org, the first is outdated too, the second is current.\n(I don't yet completely know how things should be done).\n"},{"id":"101926","messageId":"20090126011847.GA8703@dcvr.yhbt.net","threadId":"17351","inReplyTo":"497CEC56.3020900@tut.by","subject":"Re: [PATCH] git-svn: add --ignore-paths option for fetching","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2009-01-26T01:18:47Z","receivedAt":"2009-01-26T01:18:47Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"public_vi <public_vi@tut.by> wrote:\n> Eric Wong wrote:\n>> Thomas Rast <trast@student.ethz.ch> wrote:\n>>   \n>>\n>> Also, indentation is always done with tabs in git-svn (and the vast\n>> majority of git as well).\n>>\n>>   \n> Whitespace is invisible for me now, I only checked according to  \n> Documentation/SubmittingPatches about extra lines adds or removes caused  \n> just by whitespace difference.\n>>\n>>\n>> Vitaly: thank you for the patch.  Can you also provide a testcase to\n>> ensure this functionality doesn't break during refactorings?  Thanks.\n>>\n>>   \n> Already done it with testcase. There are two new packs of patches sent  \n> to git@vger.kernel.org, the first is outdated too, the second is current.\n> (I don't yet completely know how things should be done).\n\nThanks Vitaly, acked and pushed out with minor fixes to\ngit://git.bogomips.org/git-svn.git\n\ngit-svn: Add test for --ignore-paths parameter\n    [ew: replaced 'echo -e' with printf so it works on POSIX shells]\n    [ew: added Vitaly to copyright even though it's based on my test]\n\ngit-svn: documented --ignore-paths\n    [ew: trailing whitespace removed]\n\ngit-svn: add --ignore-paths option for fetching\n    [ew: replaced 4-space indent with tabs]\n    [ew: prefixed $ignore_regex with an underscore to be consistent\n         with other globals in git-svn]\n    [ew: rearranged functions to minimize diff and removed prototype\n         usage to be consistent with the rest of git-svn (and other\n         Perl code in git (and they're ugly to me)]\n\n-- \nEric Wong\n"},{"id":"101945","messageId":"7veiyqa8d2.fsf@gitster.siamese.dyndns.org","threadId":"17351","inReplyTo":"20090126011847.GA8703@dcvr.yhbt.net","subject":"Re: [PATCH] git-svn: add --ignore-paths option for fetching","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2009-01-26T06:28:57Z","receivedAt":"2009-01-26T06:28:57Z","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> Thanks Vitaly, acked and pushed out with minor fixes to\n> git://git.bogomips.org/git-svn.git\n\nPulled; thanks.\n"}]}