git-svn: --follow-parent tracks multi-parent paths
authorEric Wong <normalperson@yhbt.net>
Fri, 9 Feb 2007 09:28:30 +0000 (01:28 -0800)
committerEric Wong <normalperson@yhbt.net>
Fri, 23 Feb 2007 08:57:11 +0000 (00:57 -0800)
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>
git-svn.perl
t/t9104-git-svn-follow-parent.sh

index 21d53054f6638198c47af64f22a5fcdab3cea249..cd35efec7e175838c2de855d404247609c16d64e 100755 (executable)
@@ -1266,11 +1266,19 @@ sub do_fetch {
        my ($self, $paths, $rev) = @_;
        my $ed;
        my ($last_rev, @parents);
-       if ($self->last_commit) {
+       if (my $lc = $self->last_commit) {
+               # 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):
+               if (my $log_entry = $self->find_parent_branch($paths, $rev)) {
+                       push @{$log_entry->{parents}}, $lc;
+                       return $log_entry;
+               }
                $ed = SVN::Git::Fetcher->new($self);
                $last_rev = $self->{last_rev};
-               $ed->{c} = $self->{last_commit};
-               @parents = ($self->{last_commit});
+               $ed->{c} = $lc;
+               @parents = ($lc);
        } else {
                $last_rev = $rev;
                if (my $log_entry = $self->find_parent_branch($paths, $rev)) {
index eebb84974c098688265b174d5eed1e7f749484f6..f5b7e5efe018a548ef54f9a6684d9fb584a89fb9 100755 (executable)
@@ -146,6 +146,13 @@ test_expect_success "track initial change if it was only made to parent" "
             \"\`git rev-parse r9270-d~1\`\"
        "
 
+test_expect_success "track multi-parent paths" "
+       svn cp -m 'resurrect /glob' $svnrepo/r9270 $svnrepo/glob &&
+       git-svn multi-fetch --follow-parent &&
+       test \`git cat-file commit refs/remotes/glob | \
+              grep '^parent ' | wc -l\` -eq 2
+       "
+
 test_expect_success "multi-fetch continues to work" "
        git-svn multi-fetch --follow-parent
        "