* [PATCH] git-svn: add --ignore-paths option for fetching
@ 2009-01-25 22:21 Vitaly "_Vi" Shukela
2009-01-25 22:21 ` [PATCH] git-svn: documented --ignore-paths Vitaly "_Vi" Shukela
0 siblings, 1 reply; 10+ messages in thread
From: Vitaly "_Vi" Shukela @ 2009-01-25 22:21 UTC (permalink / raw)
To: git; +Cc: Vitaly "_Vi" Shukela
This will be useful when somebody want to checkout something partially from
repository with some non-standart layout or exclude some files from it.
Example: repository has structure /module-{a,b,c}/{trunk,branches,tags}/...
Modules are interdependent, and you want it to be single repostory (to commit
to all modules simultaneously and view complete history), but do not want
branches and tags be checked out into working copy.
Other use case is excluding some large blobs.
The quirk for now is that user must specify this option every fetch/rebase;
in other case he may get extra files or "file not found" errors. It may be
will be resolved by adding regular expression to .git/config into
[svn-remote ...] to make it persistent.
Signed-off-by: Vitaly "_Vi" Shukela <public_vi@tut.by>
---
git-svn.perl | 43 +++++++++++++++++++++++++++----------------
1 files changed, 27 insertions(+), 16 deletions(-)
diff --git a/git-svn.perl b/git-svn.perl
index d4cb538..40b0e9e 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -70,7 +70,8 @@ my ($_stdin, $_help, $_edit,
$Git::SVN::_follow_parent = 1;
my %remote_opts = ( 'username=s' => \$Git::SVN::Prompt::_username,
'config-dir=s' => \$Git::SVN::Ra::config_dir,
- 'no-auth-cache' => \$Git::SVN::Prompt::_no_auth_cache );
+ 'no-auth-cache' => \$Git::SVN::Prompt::_no_auth_cache,
+ 'ignore-paths=s' => \$SVN::Git::Fetcher::ignore_regex );
my %fc_opts = ( 'follow-parent|follow!' => \$Git::SVN::_follow_parent,
'authors-file|A=s' => \$_authors,
'repack:i' => \$Git::SVN::_repack,
@@ -3245,6 +3246,21 @@ use warnings;
use Carp qw/croak/;
use File::Temp qw/tempfile/;
use IO::File qw//;
+use vars qw/ $ignore_regex/;
+
+# returns true if a given path is inside a ".git" directory
+sub in_dot_git($) {
+ $_[0] =~ m{(?:^|/)\.git(?:/|$)};
+}
+
+# 0 -- don't ignore, 1 -- ignore
+sub is_path_ignored($) {
+ my ($path) = @_;
+ return 1 if in_dot_git($path);
+ return 0 unless defined($ignore_regex);
+ return 1 if $path =~ m!$ignore_regex!o;
+ return 0;
+}
# file baton members: path, mode_a, mode_b, pool, fh, blob, base
sub new {
@@ -3292,11 +3308,6 @@ sub _mark_empty_symlinks {
\%ret;
}
-# returns true if a given path is inside a ".git" directory
-sub in_dot_git {
- $_[0] =~ m{(?:^|/)\.git(?:/|$)};
-}
-
sub set_path_strip {
my ($self, $path) = @_;
$self->{path_strip} = qr/^\Q$path\E(\/|$)/ if length $path;
@@ -3322,7 +3333,7 @@ sub git_path {
sub delete_entry {
my ($self, $path, $rev, $pb) = @_;
- return undef if in_dot_git($path);
+ return undef if is_path_ignored($path);
my $gpath = $self->git_path($path);
return undef if ($gpath eq '');
@@ -3352,7 +3363,7 @@ sub open_file {
my ($self, $path, $pb, $rev) = @_;
my ($mode, $blob);
- goto out if in_dot_git($path);
+ goto out if is_path_ignored($path);
my $gpath = $self->git_path($path);
($mode, $blob) = (command('ls-tree', $self->{c}, '--', $gpath)
@@ -3372,7 +3383,7 @@ sub add_file {
my ($self, $path, $pb, $cp_path, $cp_rev) = @_;
my $mode;
- if (!in_dot_git($path)) {
+ if (!is_path_ignored($path)) {
my ($dir, $file) = ($path =~ m#^(.*?)/?([^/]+)$#);
delete $self->{empty}->{$dir};
$mode = '100644';
@@ -3383,7 +3394,7 @@ sub add_file {
sub add_directory {
my ($self, $path, $cp_path, $cp_rev) = @_;
- goto out if in_dot_git($path);
+ goto out if is_path_ignored($path);
my $gpath = $self->git_path($path);
if ($gpath eq '') {
my ($ls, $ctx) = command_output_pipe(qw/ls-tree
@@ -3407,7 +3418,7 @@ out:
sub change_dir_prop {
my ($self, $db, $prop, $value) = @_;
- return undef if in_dot_git($db->{path});
+ return undef if is_path_ignored($db->{path});
$self->{dir_prop}->{$db->{path}} ||= {};
$self->{dir_prop}->{$db->{path}}->{$prop} = $value;
undef;
@@ -3415,7 +3426,7 @@ sub change_dir_prop {
sub absent_directory {
my ($self, $path, $pb) = @_;
- return undef if in_dot_git($pb->{path});
+ return undef if is_path_ignored($path);
$self->{absent_dir}->{$pb->{path}} ||= [];
push @{$self->{absent_dir}->{$pb->{path}}}, $path;
undef;
@@ -3423,7 +3434,7 @@ sub absent_directory {
sub absent_file {
my ($self, $path, $pb) = @_;
- return undef if in_dot_git($pb->{path});
+ return undef if is_path_ignored($path);
$self->{absent_file}->{$pb->{path}} ||= [];
push @{$self->{absent_file}->{$pb->{path}}}, $path;
undef;
@@ -3431,7 +3442,7 @@ sub absent_file {
sub change_file_prop {
my ($self, $fb, $prop, $value) = @_;
- return undef if in_dot_git($fb->{path});
+ return undef if is_path_ignored($fb->{path});
if ($prop eq 'svn:executable') {
if ($fb->{mode_b} != 120000) {
$fb->{mode_b} = defined $value ? 100755 : 100644;
@@ -3447,7 +3458,7 @@ sub change_file_prop {
sub apply_textdelta {
my ($self, $fb, $exp) = @_;
- return undef if (in_dot_git($fb->{path}));
+ return undef if 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
@@ -3494,7 +3505,7 @@ sub apply_textdelta {
sub close_file {
my ($self, $fb, $exp) = @_;
- return undef if (in_dot_git($fb->{path}));
+ return undef if is_path_ignored($fb->{path});
my $hash;
my $path = $self->git_path($fb->{path});
--
1.5.6.5
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH] git-svn: documented --ignore-paths
2009-01-25 22:21 [PATCH] git-svn: add --ignore-paths option for fetching Vitaly "_Vi" Shukela
@ 2009-01-25 22:21 ` Vitaly "_Vi" Shukela
2009-01-25 22:21 ` [PATCH] git-svn: Add test for --ignore-paths parameter Vitaly "_Vi" Shukela
0 siblings, 1 reply; 10+ messages in thread
From: Vitaly "_Vi" Shukela @ 2009-01-25 22:21 UTC (permalink / raw)
To: git; +Cc: Vitaly "_Vi" Shukela
Documented --ignore-paths option of git-svn to inform users about
the feature and provide some examples.
Signed-off-by: Vitaly "_Vi" Shukela <public_vi@tut.by>
---
Documentation/git-svn.txt | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt
index 63d2f5e..2215fcb 100644
--- a/Documentation/git-svn.txt
+++ b/Documentation/git-svn.txt
@@ -103,6 +103,19 @@ repository to be able to interoperate with someone else's local Git
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
+ cause skipping of all matching paths from checkout from SVN.
+ Examples:
+
+ --ignore-paths="^doc" - skip "doc*" directory for every fetch.
+
+ --ignore-paths="^[^/]+/(?:branches|tags)" - skip "branches"
+ and "tags" of first level directories.
+
+ Regular expression is not persistent, you should specify
+ it every time when fetching.
+
'clone'::
Runs 'init' and 'fetch'. It will automatically create a
directory based on the basename of the URL passed to it;
--
1.5.6.5
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH] git-svn: Add test for --ignore-paths parameter
2009-01-25 22:21 ` [PATCH] git-svn: documented --ignore-paths Vitaly "_Vi" Shukela
@ 2009-01-25 22:21 ` Vitaly "_Vi" Shukela
0 siblings, 0 replies; 10+ messages in thread
From: Vitaly "_Vi" Shukela @ 2009-01-25 22:21 UTC (permalink / raw)
To: git; +Cc: Vitaly "_Vi" Shukela
Added a test for this option, similar to (and based on) t9133 about ignorance of .git directories
Signed-off-by: Vitaly "_Vi" Shukela <public_vi@tut.by>
---
t/t9134-git-svn-ignore-paths.sh | 97 +++++++++++++++++++++++++++++++++++++++
1 files changed, 97 insertions(+), 0 deletions(-)
create mode 100755 t/t9134-git-svn-ignore-paths.sh
diff --git a/t/t9134-git-svn-ignore-paths.sh b/t/t9134-git-svn-ignore-paths.sh
new file mode 100755
index 0000000..094cb6a
--- /dev/null
+++ b/t/t9134-git-svn-ignore-paths.sh
@@ -0,0 +1,97 @@
+#!/bin/sh
+#
+# Copyright (c) 2009 Eric Wong
+#
+
+test_description='git svn property tests'
+. ./lib-git-svn.sh
+
+test_expect_success 'setup test repository' '
+ svn co "$svnrepo" s &&
+ (
+ cd s &&
+ mkdir qqq www &&
+ echo test_qqq > qqq/test_qqq.txt &&
+ echo test_www > www/test_www.txt &&
+ svn add qqq &&
+ svn add www &&
+ svn commit -m "create some files" &&
+ svn up &&
+ echo hi >> www/test_www.txt &&
+ svn commit -m "modify www/test_www.txt" &&
+ svn up
+ )
+'
+
+test_expect_success 'clone an SVN repository with ignored www directory' '
+ git svn clone --ignore-paths="^www" "$svnrepo" g &&
+ echo test_qqq > expect &&
+ for i in g/*/*.txt; do cat $i >> expect2; done &&
+ test_cmp expect expect2
+'
+
+test_expect_success 'SVN-side change outside of www' '
+ (
+ cd s &&
+ echo b >> qqq/test_qqq.txt &&
+ svn commit -m "SVN-side change outside of www" &&
+ svn up &&
+ svn log -v | fgrep "SVN-side change outside of www"
+ )
+'
+
+test_expect_success 'update git svn-cloned repo' '
+ (
+ cd g &&
+ git svn rebase --ignore-paths="^www" &&
+ echo -e "test_qqq\nb" > expect &&
+ for i in */*.txt; do cat $i >> expect2; done &&
+ test_cmp expect2 expect &&
+ rm expect expect2
+ )
+'
+
+test_expect_success 'SVN-side change inside of ignored www' '
+ (
+ cd s &&
+ echo zaq >> www/test_www.txt
+ svn commit -m "SVN-side change inside of www/test_www.txt" &&
+ svn up &&
+ svn log -v | fgrep "SVN-side change inside of www/test_www.txt"
+ )
+'
+
+test_expect_success 'update git svn-cloned repo' '
+ (
+ cd g &&
+ git svn rebase --ignore-paths="^www" &&
+ echo -e "test_qqq\nb" > expect &&
+ for i in */*.txt; do cat $i >> expect2; done &&
+ test_cmp expect2 expect &&
+ rm expect expect2
+ )
+'
+
+test_expect_success 'SVN-side change in and out of ignored www' '
+ (
+ cd s &&
+ echo cvf >> www/test_www.txt
+ echo ygg >> qqq/test_qqq.txt
+ svn commit -m "SVN-side change in and out of ignored www" &&
+ svn up &&
+ svn log -v | fgrep "SVN-side change in and out of ignored www"
+ )
+'
+
+test_expect_success 'update git svn-cloned repo again' '
+ (
+ cd g &&
+ git svn rebase --ignore-paths="^www" &&
+ echo -e "test_qqq\nb\nygg" > expect &&
+ for i in */*.txt; do cat $i >> expect2; done &&
+ test_cmp expect2 expect &&
+ rm expect expect2
+ )
+'
+
+test_done
--
1.5.6.5
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH] git-svn: add --ignore-paths option for fetching
@ 2009-01-25 6:27 Vitaly "_Vi" Shukela
2009-01-25 14:21 ` Thomas Rast
0 siblings, 1 reply; 10+ messages in thread
From: Vitaly "_Vi" Shukela @ 2009-01-25 6:27 UTC (permalink / raw)
To: git, normalperson; +Cc: Vitaly "_Vi" Shukela
Signed-off-by: Vitaly "_Vi" Shukela <public_vi@tut.by>
---
Documentation/git-svn.txt | 4 ++++
git-svn.perl | 25 +++++++++++++++++++++++--
2 files changed, 27 insertions(+), 2 deletions(-)
diff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt
index 63d2f5e..4aeb88b 100644
--- a/Documentation/git-svn.txt
+++ b/Documentation/git-svn.txt
@@ -96,6 +96,10 @@ COMMANDS
Store Git commit times in the local timezone instead of UTC. This
makes 'git-log' (even without --date=local) show the same times
that `svn log` would in the local timezone.
+--ignore-paths=<regex>;;
+ This allows one to specify regular expression that will
+ cause skipping of all matching paths from checkout from SVN.
+ Example: --ignore-paths='^doc'
This doesn't interfere with interoperating with the Subversion
repository you cloned from, but if you wish for your local Git
diff --git a/git-svn.perl b/git-svn.perl
index d4cb538..4909b23 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -70,7 +70,8 @@ my ($_stdin, $_help, $_edit,
$Git::SVN::_follow_parent = 1;
my %remote_opts = ( 'username=s' => \$Git::SVN::Prompt::_username,
'config-dir=s' => \$Git::SVN::Ra::config_dir,
- 'no-auth-cache' => \$Git::SVN::Prompt::_no_auth_cache );
+ 'no-auth-cache' => \$Git::SVN::Prompt::_no_auth_cache,
+ 'ignore-paths=s' => \$SVN::Git::Fetcher::ignoreRegex );
my %fc_opts = ( 'follow-parent|follow!' => \$Git::SVN::_follow_parent,
'authors-file|A=s' => \$_authors,
'repack:i' => \$Git::SVN::_repack,
@@ -3245,6 +3246,15 @@ use warnings;
use Carp qw/croak/;
use File::Temp qw/tempfile/;
use IO::File qw//;
+use vars qw/ $ignoreRegex/;
+
+# 0 -- don't ignore, 1 -- ignore
+sub isPathIgnored($) {
+ return 0 unless defined($ignoreRegex);
+ my $path = shift;
+ return 1 if $path =~ m!^$ignoreRegex!o;
+ return 0;
+}
# file baton members: path, mode_a, mode_b, pool, fh, blob, base
sub new {
@@ -3323,6 +3333,7 @@ sub git_path {
sub delete_entry {
my ($self, $path, $rev, $pb) = @_;
return undef if in_dot_git($path);
+ return undef if isPathIgnored($path);
my $gpath = $self->git_path($path);
return undef if ($gpath eq '');
@@ -3353,6 +3364,7 @@ sub open_file {
my ($mode, $blob);
goto out if in_dot_git($path);
+ goto out if isPathIgnored($path);
my $gpath = $self->git_path($path);
($mode, $blob) = (command('ls-tree', $self->{c}, '--', $gpath)
@@ -3372,11 +3384,14 @@ sub add_file {
my ($self, $path, $pb, $cp_path, $cp_rev) = @_;
my $mode;
+ goto out if isPathIgnored($path);
+
if (!in_dot_git($path)) {
my ($dir, $file) = ($path =~ m#^(.*?)/?([^/]+)$#);
delete $self->{empty}->{$dir};
$mode = '100644';
}
+out:
{ path => $path, mode_a => $mode, mode_b => $mode,
pool => SVN::Pool->new, action => 'A' };
}
@@ -3384,6 +3399,7 @@ sub add_file {
sub add_directory {
my ($self, $path, $cp_path, $cp_rev) = @_;
goto out if in_dot_git($path);
+ goto out if isPathIgnored($path);
my $gpath = $self->git_path($path);
if ($gpath eq '') {
my ($ls, $ctx) = command_output_pipe(qw/ls-tree
@@ -3408,6 +3424,7 @@ out:
sub change_dir_prop {
my ($self, $db, $prop, $value) = @_;
return undef if in_dot_git($db->{path});
+ return undef if isPathIgnored($db->{path});
$self->{dir_prop}->{$db->{path}} ||= {};
$self->{dir_prop}->{$db->{path}}->{$prop} = $value;
undef;
@@ -3416,6 +3433,7 @@ sub change_dir_prop {
sub absent_directory {
my ($self, $path, $pb) = @_;
return undef if in_dot_git($pb->{path});
+ return undef if isPathIgnored($path);
$self->{absent_dir}->{$pb->{path}} ||= [];
push @{$self->{absent_dir}->{$pb->{path}}}, $path;
undef;
@@ -3424,6 +3442,7 @@ sub absent_directory {
sub absent_file {
my ($self, $path, $pb) = @_;
return undef if in_dot_git($pb->{path});
+ return undef if isPathIgnored($path);
$self->{absent_file}->{$pb->{path}} ||= [];
push @{$self->{absent_file}->{$pb->{path}}}, $path;
undef;
@@ -3432,6 +3451,7 @@ sub absent_file {
sub change_file_prop {
my ($self, $fb, $prop, $value) = @_;
return undef if in_dot_git($fb->{path});
+ return undef if isPathIgnored($fb->{path});
if ($prop eq 'svn:executable') {
if ($fb->{mode_b} != 120000) {
$fb->{mode_b} = defined $value ? 100755 : 100644;
@@ -3448,6 +3468,7 @@ sub change_file_prop {
sub apply_textdelta {
my ($self, $fb, $exp) = @_;
return undef if (in_dot_git($fb->{path}));
+ return undef if isPathIgnored($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
@@ -3495,7 +3516,7 @@ sub apply_textdelta {
sub close_file {
my ($self, $fb, $exp) = @_;
return undef if (in_dot_git($fb->{path}));
-
+ return undef if isPathIgnored($fb->{path});
my $hash;
my $path = $self->git_path($fb->{path});
if (my $fh = $fb->{fh}) {
--
1.5.6.5
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] git-svn: add --ignore-paths option for fetching
2009-01-25 6:27 [PATCH] git-svn: add --ignore-paths option for fetching Vitaly "_Vi" Shukela
@ 2009-01-25 14:21 ` Thomas Rast
2009-01-25 16:29 ` public_vi
2009-01-25 22:42 ` Eric Wong
0 siblings, 2 replies; 10+ messages in thread
From: Thomas Rast @ 2009-01-25 14:21 UTC (permalink / raw)
To: Vitaly "_Vi" Shukela; +Cc: git, normalperson
[-- Attachment #1: Type: text/plain, Size: 2384 bytes --]
Vitaly "_Vi" Shukela wrote:
>
> Signed-off-by: Vitaly "_Vi" Shukela <public_vi@tut.by>
This would be a good place to explain why this is useful, and (if
applicable) why you chose to implement it the way you did.
> --- a/Documentation/git-svn.txt
> +++ b/Documentation/git-svn.txt
> @@ -96,6 +96,10 @@ COMMANDS
> Store Git commit times in the local timezone instead of UTC. This
> makes 'git-log' (even without --date=local) show the same times
> that `svn log` would in the local timezone.
> +--ignore-paths=<regex>;;
> + This allows one to specify regular expression that will
> + cause skipping of all matching paths from checkout from SVN.
> + Example: --ignore-paths='^doc'
>
> This doesn't interfere with interoperating with the Subversion
> repository you cloned from, but if you wish for your local Git
You put the --ignore-paths explanation in the middle of the
--localtime documentation (the last paragraph quoted still talks about
--localtime).
> @@ -3245,6 +3246,15 @@ use warnings;
> use Carp qw/croak/;
> use File::Temp qw/tempfile/;
> use IO::File qw//;
> +use vars qw/ $ignoreRegex/;
> +
> +# 0 -- don't ignore, 1 -- ignore
> +sub isPathIgnored($) {
> + return 0 unless defined($ignoreRegex);
> + my $path = shift;
> + return 1 if $path =~ m!^$ignoreRegex!o;
> + return 0;
> +}
This is the first function in git-svn.perl using camelCase. Consider
sticking to the current style and spelling it is_path_ignored().
> @@ -3372,11 +3384,14 @@ sub add_file {
> my ($self, $path, $pb, $cp_path, $cp_rev) = @_;
> my $mode;
>
> + goto out if isPathIgnored($path);
> +
> if (!in_dot_git($path)) {
> my ($dir, $file) = ($path =~ m#^(.*?)/?([^/]+)$#);
> delete $self->{empty}->{$dir};
> $mode = '100644';
> }
> +out:
> { path => $path, mode_a => $mode, mode_b => $mode,
> pool => SVN::Pool->new, action => 'A' };
> }
You broke the symmetry here, while all other hunks just add an
equivalent check to the existing in_dot_git().
However, the latter makes me wonder if it would be cleaner to move the
in_dot_git() test to isPathIgnored (er, is_path_ignored) too?
FWIW, I like the feature; it seems a good way to exclude subtrees with
large blobs, and I know several SVN repos that have such a directory.
--
Thomas Rast
trast@{inf,student}.ethz.ch
[-- Attachment #2: This is a digitally signed message part. --]
[-- Type: application/pgp-signature, Size: 197 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] git-svn: add --ignore-paths option for fetching
2009-01-25 14:21 ` Thomas Rast
@ 2009-01-25 16:29 ` public_vi
2009-01-25 22:42 ` Eric Wong
1 sibling, 0 replies; 10+ messages in thread
From: public_vi @ 2009-01-25 16:29 UTC (permalink / raw)
To: Thomas Rast; +Cc: git, normalperson
It is useful for me, but I think I can be useful for others too.
May be it's better to make in inclusive, i.e. "--only-matching=<regex>"?
> This would be a good place to explain why this is useful, and (if
> applicable) why you chose to implement it the way you did.
>
OK, fixing them.
> You put the --ignore-paths explanation in the middle of the
> --localtime documentation (the last paragraph quoted still talks about
> --localtime).
>
> This is the first function in git-svn.perl using camelCase. Consider
> sticking to the current style and spelling it is_path_ignored().
>
> You broke the symmetry here, while all other hunks just add an
> equivalent check to the existing in_dot_git().
>
> However, the latter makes me wonder if it would be cleaner to move the
> in_dot_git() test to isPathIgnored (er, is_path_ignored) too?
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] git-svn: add --ignore-paths option for fetching
2009-01-25 14:21 ` Thomas Rast
2009-01-25 16:29 ` public_vi
@ 2009-01-25 22:42 ` Eric Wong
2009-01-25 22:48 ` public_vi
1 sibling, 1 reply; 10+ messages in thread
From: Eric Wong @ 2009-01-25 22:42 UTC (permalink / raw)
To: Thomas Rast; +Cc: Vitaly _Vi Shukela, git
Thomas Rast <trast@student.ethz.ch> wrote:
> Vitaly "_Vi" Shukela wrote:
> >
> > Signed-off-by: Vitaly "_Vi" Shukela <public_vi@tut.by>
>
> This would be a good place to explain why this is useful, and (if
> applicable) why you chose to implement it the way you did.
>
> > --- a/Documentation/git-svn.txt
> > +++ b/Documentation/git-svn.txt
> > @@ -96,6 +96,10 @@ COMMANDS
> > Store Git commit times in the local timezone instead of UTC. This
> > makes 'git-log' (even without --date=local) show the same times
> > that `svn log` would in the local timezone.
> > +--ignore-paths=<regex>;;
> > + This allows one to specify regular expression that will
> > + cause skipping of all matching paths from checkout from SVN.
> > + Example: --ignore-paths='^doc'
> >
> > This doesn't interfere with interoperating with the Subversion
> > repository you cloned from, but if you wish for your local Git
>
> You put the --ignore-paths explanation in the middle of the
> --localtime documentation (the last paragraph quoted still talks about
> --localtime).
>
> > @@ -3245,6 +3246,15 @@ use warnings;
> > use Carp qw/croak/;
> > use File::Temp qw/tempfile/;
> > use IO::File qw//;
> > +use vars qw/ $ignoreRegex/;
> > +
> > +# 0 -- don't ignore, 1 -- ignore
> > +sub isPathIgnored($) {
> > + return 0 unless defined($ignoreRegex);
> > + my $path = shift;
> > + return 1 if $path =~ m!^$ignoreRegex!o;
> > + return 0;
> > +}
>
> This is the first function in git-svn.perl using camelCase. Consider
> sticking to the current style and spelling it is_path_ignored().
Also, indentation is always done with tabs in git-svn (and the vast
majority of git as well).
> > @@ -3372,11 +3384,14 @@ sub add_file {
> > my ($self, $path, $pb, $cp_path, $cp_rev) = @_;
> > my $mode;
> >
> > + goto out if isPathIgnored($path);
> > +
> > if (!in_dot_git($path)) {
> > my ($dir, $file) = ($path =~ m#^(.*?)/?([^/]+)$#);
> > delete $self->{empty}->{$dir};
> > $mode = '100644';
> > }
> > +out:
> > { path => $path, mode_a => $mode, mode_b => $mode,
> > pool => SVN::Pool->new, action => 'A' };
> > }
>
> You broke the symmetry here, while all other hunks just add an
> equivalent check to the existing in_dot_git().
>
> However, the latter makes me wonder if it would be cleaner to move the
> in_dot_git() test to isPathIgnored (er, is_path_ignored) too?
Thanks for the review, Thomas. I agree with all your suggestions.
Vitaly: thank you for the patch. Can you also provide a testcase to
ensure this functionality doesn't break during refactorings? Thanks.
--
Eric Wong
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] git-svn: add --ignore-paths option for fetching
2009-01-25 22:42 ` Eric Wong
@ 2009-01-25 22:48 ` public_vi
2009-01-26 1:18 ` Eric Wong
0 siblings, 1 reply; 10+ messages in thread
From: public_vi @ 2009-01-25 22:48 UTC (permalink / raw)
To: Eric Wong; +Cc: Thomas Rast, git
Eric Wong wrote:
> Thomas Rast <trast@student.ethz.ch> wrote:
>
>
> Also, indentation is always done with tabs in git-svn (and the vast
> majority of git as well).
>
>
Whitespace is invisible for me now, I only checked according to
Documentation/SubmittingPatches about extra lines adds or removes caused
just by whitespace difference.
>
>
> Vitaly: thank you for the patch. Can you also provide a testcase to
> ensure this functionality doesn't break during refactorings? Thanks.
>
>
Already done it with testcase. There are two new packs of patches sent
to git@vger.kernel.org, the first is outdated too, the second is current.
(I don't yet completely know how things should be done).
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] git-svn: add --ignore-paths option for fetching
2009-01-25 22:48 ` public_vi
@ 2009-01-26 1:18 ` Eric Wong
2009-01-26 6:28 ` Junio C Hamano
0 siblings, 1 reply; 10+ messages in thread
From: Eric Wong @ 2009-01-26 1:18 UTC (permalink / raw)
To: public_vi; +Cc: Thomas Rast, git
public_vi <public_vi@tut.by> wrote:
> Eric Wong wrote:
>> Thomas Rast <trast@student.ethz.ch> wrote:
>>
>>
>> Also, indentation is always done with tabs in git-svn (and the vast
>> majority of git as well).
>>
>>
> Whitespace is invisible for me now, I only checked according to
> Documentation/SubmittingPatches about extra lines adds or removes caused
> just by whitespace difference.
>>
>>
>> Vitaly: thank you for the patch. Can you also provide a testcase to
>> ensure this functionality doesn't break during refactorings? Thanks.
>>
>>
> Already done it with testcase. There are two new packs of patches sent
> to git@vger.kernel.org, the first is outdated too, the second is current.
> (I don't yet completely know how things should be done).
Thanks Vitaly, acked and pushed out with minor fixes to
git://git.bogomips.org/git-svn.git
git-svn: Add test for --ignore-paths parameter
[ew: replaced 'echo -e' with printf so it works on POSIX shells]
[ew: added Vitaly to copyright even though it's based on my test]
git-svn: documented --ignore-paths
[ew: trailing whitespace removed]
git-svn: add --ignore-paths option for fetching
[ew: replaced 4-space indent with tabs]
[ew: prefixed $ignore_regex with an underscore to be consistent
with other globals in git-svn]
[ew: rearranged functions to minimize diff and removed prototype
usage to be consistent with the rest of git-svn (and other
Perl code in git (and they're ugly to me)]
--
Eric Wong
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2009-01-26 6:31 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-01-25 22:21 [PATCH] git-svn: add --ignore-paths option for fetching Vitaly "_Vi" Shukela
2009-01-25 22:21 ` [PATCH] git-svn: documented --ignore-paths Vitaly "_Vi" Shukela
2009-01-25 22:21 ` [PATCH] git-svn: Add test for --ignore-paths parameter Vitaly "_Vi" Shukela
-- strict thread matches above, loose matches on Subject: below --
2009-01-25 6:27 [PATCH] git-svn: add --ignore-paths option for fetching Vitaly "_Vi" Shukela
2009-01-25 14:21 ` Thomas Rast
2009-01-25 16:29 ` public_vi
2009-01-25 22:42 ` Eric Wong
2009-01-25 22:48 ` public_vi
2009-01-26 1:18 ` Eric Wong
2009-01-26 6:28 ` 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).