summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3c49a03)
raw | patch | inline | side by side (parent: 3c49a03)
author | Mattias Nissler <mattias.nissler@gmx.de> | |
Mon, 6 Jul 2009 23:40:02 +0000 (01:40 +0200) | ||
committer | Eric Wong <normalperson@yhbt.net> | |
Sat, 11 Jul 2009 21:14:32 +0000 (14:14 -0700) |
For the case of multiple projects sharing a single SVN repository, it is
common practice to create the standard SVN directory layout within a
subdirectory for each project. In such setups, access control is often
used to limit what projects a given user may access. git-svn failed to
detect branches (e.g. when passing --stdlayout to clone) because it
relied on having access to the root directory in the repository. This
patch solves this problem by making git-svn use paths relative to the
given repository URL instead of the repository root.
Signed-off-by: Mattias Nissler <mattias.nissler@gmx.de>
Acked-by: Eric Wong <normalperson@yhbt.net>
common practice to create the standard SVN directory layout within a
subdirectory for each project. In such setups, access control is often
used to limit what projects a given user may access. git-svn failed to
detect branches (e.g. when passing --stdlayout to clone) because it
relied on having access to the root directory in the repository. This
patch solves this problem by making git-svn use paths relative to the
given repository URL instead of the repository root.
Signed-off-by: Mattias Nissler <mattias.nissler@gmx.de>
Acked-by: Eric Wong <normalperson@yhbt.net>
git-svn.perl | patch | blob | history | |
t/t9138-git-svn-multiple-branches.sh | patch | blob | history |
diff --git a/git-svn.perl b/git-svn.perl
index b4e8d44351c4b0a5744e41def1fd0858e3bbb6a6..ec847580d60d1b77d845bd86a852ada836ba31fd 100755 (executable)
--- a/git-svn.perl
+++ b/git-svn.perl
usage(1);
}
- # there are currently some bugs that prevent multi-init/multi-fetch
- # setups from working well without this.
- $Git::SVN::_minimize_url = 1;
-
$_prefix = '' unless defined $_prefix;
if (defined $url) {
$url = canonicalize_url($url);
"wanted to set to: $gs->{url}\n";
}
command_oneline('config', $k, $gs->{url}) unless $orig_url;
- my $remote_path = "$ra->{svn_path}/$repo_path";
+ my $remote_path = "$gs->{path}/$repo_path";
$remote_path =~ s#/+#/#g;
$remote_path =~ s#^/##g;
$remote_path .= "/*" if $remote_path !~ /\*/;
$ra;
}
-sub rel_path {
- my ($self) = @_;
- my $repos_root = $self->ra->{repos_root};
- return $self->{path} if ($self->{url} eq $repos_root);
- my $url = $self->{url} .
- (length $self->{path} ? "/$self->{path}" : $self->{path});
- $url =~ s!^\Q$repos_root\E(?:/+|$)!!g;
- $url;
-}
-
# prop_walk(PATH, REV, SUB)
# -------------------------
# Recursively traverse PATH at revision REV and invoke SUB for each
if (my $path = $paths->{"/$self->{path}"}) {
return ($path->{action} eq 'D') ? 0 : 1;
}
- my $repos_root = $self->ra->{repos_root};
- my $extended_path = $self->{url} . '/' . $self->{path};
- $extended_path =~ s#^\Q$repos_root\E(/|$)##;
- $self->{path_regex} ||= qr/^\/\Q$extended_path\E\//;
+ $self->{path_regex} ||= qr/^\/\Q$self->{path}\E\//;
if (grep /$self->{path_regex}/, keys %$paths) {
return 1;
}
return undef unless defined $paths;
# look for a parent from another branch:
- my @b_path_components = split m#/#, $self->rel_path;
+ my @b_path_components = split m#/#, $self->{path};
my @a_path_components;
my $i;
while (@b_path_components) {
my $r = $i->{copyfrom_rev};
my $repos_root = $self->ra->{repos_root};
my $url = $self->ra->{url};
- my $new_url = $repos_root . $branch_from;
+ my $new_url = $url . $branch_from;
print STDERR "Found possible branch point: ",
"$new_url => ", $self->full_url, ", $r\n";
$branch_from =~ s#^/##;
- my $gs = $self->other_gs($new_url, $url, $repos_root,
+ my $gs = $self->other_gs($new_url, $url,
$branch_from, $r, $self->{ref_id});
my ($r0, $parent) = $gs->find_rev_before($r, 1);
{
}
sub other_gs {
- my ($self, $new_url, $url, $repos_root,
+ my ($self, $new_url, $url,
$branch_from, $r, $old_ref_id) = @_;
- my $gs = Git::SVN->find_by_url($new_url, $repos_root, $branch_from);
+ my $gs = Git::SVN->find_by_url($new_url, $url, $branch_from);
unless ($gs) {
my $ref_id = $old_ref_id;
$ref_id =~ s/\@\d+$//;
# externally passed pool (instead of our temporary and quickly cleared
# pool in Git::SVN::Ra) does not help matters at all...
my $receiver = pop @args;
+ my $prefix = "/".$self->{svn_path};
+ $prefix =~ s#/+($)##;
+ my $prefix_regex = qr#^\Q$prefix\E#;
push(@args, sub {
my ($paths) = $_[0];
return &$receiver(@_) unless $paths;
$_[0] = ();
foreach my $p (keys %$paths) {
my $i = $paths->{$p};
- my %s = map { $_ => $i->$_ }
- qw/copyfrom_path copyfrom_rev action/;
+ # Make path relative to our url, not repos_root
+ $p =~ s/$prefix_regex//;
+ my %s = map { $_ => $i->$_; }
+ qw/copyfrom_path copyfrom_rev action/;
+ if ($s{'copyfrom_path'}) {
+ $s{'copyfrom_path'} =~ s/$prefix_regex//;
+ }
$_[0]{$p} = \%s;
}
&$receiver(@_);
index cb9a6d229d24a4f4af062642d07660c5701429f6..3cd06718eb552794e04afe0860d0fc1e187eed66 100755 (executable)
test_expect_success 'create new branches and tags' '
( cd git_project &&
- git svn branch -m "New branch 1" -d project/b_one New1 ) &&
+ git svn branch -m "New branch 1" -d b_one New1 ) &&
( cd svn_project &&
svn_cmd up && test -e b_one/New1/a.file ) &&
( cd git_project &&
- git svn branch -m "New branch 2" -d project/b_two New2 ) &&
+ git svn branch -m "New branch 2" -d b_two New2 ) &&
( cd svn_project &&
svn_cmd up && test -e b_two/New2/a.file ) &&
( cd git_project &&
- git svn branch -t -m "New tag 1" -d project/tags_A Tag1 ) &&
+ git svn branch -t -m "New tag 1" -d tags_A Tag1 ) &&
( cd svn_project &&
svn_cmd up && test -e tags_A/Tag1/a.file ) &&
( cd git_project &&
- git svn tag -m "New tag 2" -d project/tags_B Tag2 ) &&
+ git svn tag -m "New tag 2" -d tags_B Tag2 ) &&
( cd svn_project &&
svn_cmd up && test -e tags_B/Tag2/a.file )
'