aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnders Kaseorg <andersk@MIT.EDU>2008-12-28 15:27:47 -0500
committerThiago Macieira <thiago@kde.org>2009-01-08 16:58:07 +0100
commit4c4a6cf1dd9075859f59713bda04b2568ae7e115 (patch)
tree9289e3a3a15ac459a07b4bff06f7827400f84472
parentb9ea350139b68667f97e0e7f51af862f22dba6d6 (diff)
downloadsvn2git-4c4a6cf1dd9075859f59713bda04b2568ae7e115.tar
svn2git-4c4a6cf1dd9075859f59713bda04b2568ae7e115.tar.gz
svn2git-4c4a6cf1dd9075859f59713bda04b2568ae7e115.tar.bz2
svn2git-4c4a6cf1dd9075859f59713bda04b2568ae7e115.tar.xz
svn2git-4c4a6cf1dd9075859f59713bda04b2568ae7e115.zip
Read symbolic links correctly.
---1257098496-2120511158-1230496052=:2755Symlinks are described in Subversion by a file with propertysvn:special set to “*”, with contents “link <target of symlink>”. We need to strip off the “link ” when exporting to Git. Signed-off-by: Anders Kaseorg <andersk@mit.edu> Signed-off-by: Thiago Macieira <thiago@kde.org>
-rw-r--r--src/svn.cpp26
1 files changed, 20 insertions, 6 deletions
diff --git a/src/svn.cpp b/src/svn.cpp
index 5236579..3f06af7 100644
--- a/src/svn.cpp
+++ b/src/svn.cpp
@@ -220,11 +220,6 @@ static int pathMode(svn_fs_root_t *fs_root, const char *pathname, apr_pool_t *po
if (propvalue)
mode = 0100755;
- // maybe it's a symlink?
- SVN_ERR(svn_fs_node_prop(&propvalue, fs_root, pathname, "svn:special", pool));
- if (propvalue && strcmp(propvalue->data, "symlink") == 0)
- mode = 0120000;
-
return mode;
}
@@ -261,13 +256,32 @@ static int dumpBlob(Repository::Transaction *txn, svn_fs_root_t *fs_root,
svn_filesize_t stream_length;
SVN_ERR(svn_fs_file_length(&stream_length, fs_root, pathname, dumppool));
- QIODevice *io = txn->addFile(finalPathName, mode, stream_length);
#ifndef DRY_RUN
// open the file
svn_stream_t *in_stream, *out_stream;
SVN_ERR(svn_fs_file_contents(&in_stream, fs_root, pathname, dumppool));
+#endif
+ // maybe it's a symlink?
+ svn_string_t *propvalue;
+ SVN_ERR(svn_fs_node_prop(&propvalue, fs_root, pathname, "svn:special", dumppool));
+ if (propvalue) {
+ apr_size_t len = strlen("link ");
+#ifndef DRY_RUN
+ QByteArray buf;
+ buf.reserve(len);
+ SVN_ERR(svn_stream_read(in_stream, buf.data(), &len));
+ if (len != strlen("link ") || strncmp(buf, "link ", len) != 0)
+ qFatal("file %s is svn:special but not a symlink", pathname);
+#endif
+ mode = 0120000;
+ stream_length -= len;
+ }
+
+ QIODevice *io = txn->addFile(finalPathName, mode, stream_length);
+
+#ifndef DRY_RUN
// open a generic svn_stream_t for the QIODevice
out_stream = streamForDevice(io, dumppool);
SVN_ERR(svn_stream_copy(in_stream, out_stream, dumppool));