Skip to content

Commit 7fc35e0

Browse files
author
Eric Wong
committed
git-svn: workaround a for broken symlinks in SVN
It's possible for bad clients to commit symlinks without the 5-character "link " prefix in symlinks. So guard around this bug in SVN and make a best effort to create symlinks if the "link " prefix is missing. More information on this SVN bug is described here: http://subversion.tigris.org/issues/show_bug.cgi?id=2692 To be pedantic, there is still a corner case that neither we nor SVN can handle: If somebody made a link using a broken SVN client where "link " is the first part of its path, e.g. "link sausage", then we'd end up having a symlink which points to "sausage" because we incorrectly stripped the "link ". Hopefully this hasn't happened in practice, but if it has, it's not our fault SVN is broken :) Thanks to Benoit Sigoure and Sverre Johansen for reporting and feedback. Signed-off-by: Eric Wong <normalperson@yhbt.net>
1 parent ad94802 commit 7fc35e0

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

git-svn.perl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3177,9 +3177,15 @@ sub close_file {
31773177
}
31783178
sysseek($fh, 0, 0) or croak $!;
31793179
if ($fb->{mode_b} == 120000) {
3180-
sysread($fh, my $buf, 5) == 5 or croak $!;
3181-
$buf eq 'link ' or die "$path has mode 120000",
3182-
"but is not a link\n";
3180+
eval {
3181+
sysread($fh, my $buf, 5) == 5 or croak $!;
3182+
$buf eq 'link ' or die "$path has mode 120000",
3183+
" but is not a link";
3184+
};
3185+
if ($@) {
3186+
warn "$@\n";
3187+
sysseek($fh, 0, 0) or croak $!;
3188+
}
31833189
}
31843190
defined(my $pid = open my $out,'-|') or die "Can't fork: $!\n";
31853191
if (!$pid) {

0 commit comments

Comments
 (0)