git-svn: stop using path names as refnames with --follow-parent
Using path names as refnames breaks horribly if a user is tracking one large, toplevel directory, and a lower-level directory is followed from another project is a parent of another ref, as it will cause refnames such as: 'refs/remotes/trunk/path/to/stuff', which will conflict with a refname of 'refs/remotes/trunk'. Now we just append @$revno to the end of it the current refname. And if we have followed back to a grandparent, then we'll strip any existing '@$parent_revno' strings before appending our own '@$revno' string to it. Signed-off-by: Eric Wong <normalperson@yhbt.net>
Eric Wong committed
Jan 28, 2007 at 21:34 UTC
ce2a0f2f9d9fd8eee8eaa1f24a60bdafade80c24
2 files changed
+8
-4
git-svn.perl
+4
-2
@@ -1135,10 +1135,12 @@ sub find_parent_branch {
1135
last if $gs;
1136
}
1137
unless ($gs) {
1138
- my $ref_id = $branch_from;
1139
- $ref_id .= "\@$r" if find_ref($ref_id);
1138
+ my $ref_id = $self->{ref_id};
1139
+ $ref_id =~ s/\@\d+$//;
1140
+ $ref_id .= "\@$r";
1141
# just grow a tail if we're not unique enough :x
1142
$ref_id .= '-' while find_ref($ref_id);
1143
+ print STDERR "Initializing parent: $ref_id\n";
1144
$gs = Git::SVN->init($new_url, '', $ref_id, $ref_id);
1145
}
1146
my ($r0, $parent) = $gs->find_rev_before($r, 1);
t/t9104-git-svn-follow-parent.sh
+4
-2
@@ -30,10 +30,12 @@ test_expect_success 'initialize repo' "
30
test_expect_success 'init and fetch --follow-parent a moved directory' "
31
git-svn init -i thunk $svnrepo/thunk &&
32
git-svn fetch --follow-parent -i thunk &&
33
- test \"\`git-rev-parse --verify refs/remotes/trunk\`\" \
33
+ test \"\`git-rev-parse --verify refs/remotes/thunk@2\`\" \
34
= \"\`git-rev-parse --verify refs/remotes/thunk~1\`\" &&
35
test \"\`git-cat-file blob refs/remotes/thunk:readme |\
36
- sed -n -e '3p'\`\" = goodbye
36
+ sed -n -e '3p'\`\" = goodbye &&
37
+ test -n \"\`git-config --get svn-remote.git-svn.fetch \
38
+ '^trunk:refs/remotes/thunk@2$'\`\"
39
"
40
41
test_expect_success 'init and fetch from one svn-remote' "