Skip to content

Commit ce4c8b2

Browse files
Eric WongJunio C Hamano
authored andcommitted
contrib/git-svn: fix a copied-tree bug in an overzealous assertion
I thought passing --stop-on-copy to svn would save us from all the trouble svn-arch-mirror had with directory (project) copies. I was wrong, there was one thing I overlooked. If a tree was moved from /foo/trunk to /bar/foo/trunk with no other changes in r10, but the last change was done in r5, the Last Changed Rev (from svn info) in /bar/foo/trunk will still be r5, even though the copy in the repository didn't exist until r10. Now, if we ever detect that the Last Changed Rev isn't what we're expecting, we'll run svn diff and only croak if there are differences between them. Signed-off-by: Eric Wong <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f794c23 commit ce4c8b2

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

contrib/git-svn/git-svn.perl

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -337,10 +337,17 @@ sub assert_svn_wc_clean {
337337
my ($svn_rev, $treeish) = @_;
338338
croak "$svn_rev is not an integer!\n" unless ($svn_rev =~ /^\d+$/);
339339
croak "$treeish is not a sha1!\n" unless ($treeish =~ /^$sha1$/o);
340-
my $svn_info = svn_info('.');
341-
if ($svn_rev != $svn_info->{'Last Changed Rev'}) {
342-
croak "Expected r$svn_rev, got r",
343-
$svn_info->{'Last Changed Rev'},"\n";
340+
my $lcr = svn_info('.')->{'Last Changed Rev'};
341+
if ($svn_rev != $lcr) {
342+
print STDERR "Checking for copy-tree ... ";
343+
# use
344+
my @diff = grep(/^Index: /,(safe_qx(qw(svn diff),
345+
"-r$lcr:$svn_rev")));
346+
if (@diff) {
347+
croak "Nope! Expected r$svn_rev, got r$lcr\n";
348+
} else {
349+
print STDERR "OK!\n";
350+
}
344351
}
345352
my @status = grep(!/^Performing status on external/,(`svn status`));
346353
@status = grep(!/^\s*$/,@status);

0 commit comments

Comments
 (0)