aboutsummaryrefslogtreecommitdiff
path: root/git-svn.perl
diff options
context:
space:
mode:
authorDavid D. Kilzer <ddkilzer@kilzer.net>2010-08-15 06:15:55 -0700
committerEric Wong <normalperson@yhbt.net>2010-08-15 23:43:37 +0000
commit3235b7053c45a734c1cdf9b117bda68b7ced29c9 (patch)
treea6567f9bcd2cd3dbc35aea5f011ad7bed2a3049e /git-svn.perl
parent54fb7f9b08270873b0646d84164e1cebe2deb857 (diff)
downloadgit-3235b7053c45a734c1cdf9b117bda68b7ced29c9.tar.gz
git-3235b7053c45a734c1cdf9b117bda68b7ced29c9.tar.xz
git-svn: fix fetch with deleted tag
Currently git-svn assumes that two tags created from the same revision will have the same repo url, so it uses a ref to the tag without checking that its url matches the current url. This causes issues when fetching an svn repo where a tag was created, deleted, and then recreated under the following circumstances: - Both tags were copied from the same revision. - Both tags had the same name. - Both tags had different repository paths. - [Optional] Both tags have a file with the same name but different content. When all four conditions are met, a checksum mismatch error occurs because the content of two files with the same path differs (see t/t9155--git-svn-fetch-deleted-tag.sh): Checksum mismatch: ChangeLog 065854.... expected: ce771b.... got: 9563fd.... When only the first three conditions are met, no error occurs but the tag in git matches the first (deleted) tag instead of the last (most recent) tag (see t/t9156-git-svn-fetch-deleted-tag-2.sh). The fix is to verify that the repo url for the ref matches the current url. If the urls do not match, then a "tail" is grown on the tag name by appending a dash and rechecking the new ref's repo url until either a matching repo url is found or a new tag is created. Signed-off-by: David D. Kilzer <ddkilzer@kilzer.net> Acked-by: Eric Wong <normalperson@yhbt.net>
Diffstat (limited to 'git-svn.perl')
-rwxr-xr-xgit-svn.perl15
1 files changed, 13 insertions, 2 deletions
diff --git a/git-svn.perl b/git-svn.perl
index 39bcb4559..9b046b693 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -2963,14 +2963,25 @@ sub other_gs {
$ref_id .= "\@$r";
# just grow a tail if we're not unique enough :x
$ref_id .= '-' while find_ref($ref_id);
- print STDERR "Initializing parent: $ref_id\n" unless $::_q > 1;
my ($u, $p, $repo_id) = ($new_url, '', $ref_id);
if ($u =~ s#^\Q$url\E(/|$)##) {
$p = $u;
$u = $url;
$repo_id = $self->{repo_id};
}
- $gs = Git::SVN->init($u, $p, $repo_id, $ref_id, 1);
+ while (1) {
+ # It is possible to tag two different subdirectories at
+ # the same revision. If the url for an existing ref
+ # does not match, we must either find a ref with a
+ # matching url or create a new ref by growing a tail.
+ $gs = Git::SVN->init($u, $p, $repo_id, $ref_id, 1);
+ my (undef, $max_commit) = $gs->rev_map_max(1);
+ last if (!$max_commit);
+ my ($url) = ::cmt_metadata($max_commit);
+ last if ($url eq $gs->full_url);
+ $ref_id .= '-';
+ }
+ print STDERR "Initializing parent: $ref_id\n" unless $::_q > 1;
}
$gs
}