aboutsummaryrefslogtreecommitdiff
path: root/git-svn.perl
diff options
context:
space:
mode:
authorEric Wong <normalperson@yhbt.net>2007-12-19 00:06:45 -0800
committerEric Wong <normalperson@yhbt.net>2007-12-19 00:17:07 -0800
commit7fc35e0e94782bbbefb920875813519038659930 (patch)
tree440d651fee967a2a9bc5858276c26820c77bcdad /git-svn.perl
parentad94802a7bc599ade73ec0b04c61b2f80b3c1b23 (diff)
downloadgit-7fc35e0e94782bbbefb920875813519038659930.tar.gz
git-7fc35e0e94782bbbefb920875813519038659930.tar.xz
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>
Diffstat (limited to 'git-svn.perl')
-rwxr-xr-xgit-svn.perl12
1 files changed, 9 insertions, 3 deletions
diff --git a/git-svn.perl b/git-svn.perl
index 7cd62fc5c..41fedf597 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -3177,9 +3177,15 @@ sub close_file {
}
sysseek($fh, 0, 0) or croak $!;
if ($fb->{mode_b} == 120000) {
- sysread($fh, my $buf, 5) == 5 or croak $!;
- $buf eq 'link ' or die "$path has mode 120000",
- "but is not a link\n";
+ eval {
+ sysread($fh, my $buf, 5) == 5 or croak $!;
+ $buf eq 'link ' or die "$path has mode 120000",
+ " but is not a link";
+ };
+ if ($@) {
+ warn "$@\n";
+ sysseek($fh, 0, 0) or croak $!;
+ }
}
defined(my $pid = open my $out,'-|') or die "Can't fork: $!\n";
if (!$pid) {