@matheusbsbs / matheus-bagliano / commits / b9dffd8cad
Fork 0

git-svn: --follow-parent tracks multi-parent paths

We can have a branch that was deleted, then re-added under the same name but copied from another path, in which case we'll have multiple parents (we don't want to break the original ref, nor lose copypath info). Add a test for this, too, of course. Signed-off-by: Eric Wong <normalperson@yhbt.net>

Eric Wong committed Feb 9, 2007 at 01:28 UTC b9dffd8cad737a07d6a05503318c6746ac593f9c
2 files changed +18 -3
git-svn.perl
+11 -3
@@ -1266,11 +1266,19 @@ sub do_fetch {
1266 my ($self, $paths, $rev) = @_;
1267 my $ed;
1268 my ($last_rev, @parents);
1269 - if ($self->last_commit) {
1269 + if (my $lc = $self->last_commit) {
1270 + # we can have a branch that was deleted, then re-added
1271 + # under the same name but copied from another path, in
1272 + # which case we'll have multiple parents (we don't
1273 + # want to break the original ref, nor lose copypath info):
1274 + if (my $log_entry = $self->find_parent_branch($paths, $rev)) {
1275 + push @{$log_entry->{parents}}, $lc;
1276 + return $log_entry;
1277 + }
1278 $ed = SVN::Git::Fetcher->new($self);
1279 $last_rev = $self->{last_rev};
1272 - $ed->{c} = $self->{last_commit};
1273 - @parents = ($self->{last_commit});
1280 + $ed->{c} = $lc;
1281 + @parents = ($lc);
1282 } else {
1283 $last_rev = $rev;
1284 if (my $log_entry = $self->find_parent_branch($paths, $rev)) {
t/t9104-git-svn-follow-parent.sh
+7
@@ -146,6 +146,13 @@ test_expect_success "track initial change if it was only made to parent" "
146 \"\`git rev-parse r9270-d~1\`\"
147 "
148
149 +test_expect_success "track multi-parent paths" "
150 + svn cp -m 'resurrect /glob' $svnrepo/r9270 $svnrepo/glob &&
151 + git-svn multi-fetch --follow-parent &&
152 + test \`git cat-file commit refs/remotes/glob | \
153 + grep '^parent ' | wc -l\` -eq 2
154 + "
155 +
156 test_expect_success "multi-fetch continues to work" "
157 git-svn multi-fetch --follow-parent
158 "