{"thread":{"id":"19840","subject":"[PATCH] import-tars: support symlinks","startedAt":"2009-06-17T12:49:39Z","lastAt":"2009-06-17T12:49:39Z","messageCount":1,"participants":["Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"116467","messageId":"c7bf68ab386b2ce16f81d0223a27f0c82671da3b.1245242966u.git.johannes.schindelin@gmx.de","threadId":"19840","inReplyTo":"cover.1245242966u.git.johannes.schindelin@gmx.de","subject":"[PATCH] import-tars: support symlinks","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2009-06-17T12:49:39Z","receivedAt":"2009-06-17T12:49:39Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Without this patch, symbolic links are turned into empty files.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n contrib/fast-import/import-tars.perl |   17 ++++++++++++-----\n 1 files changed, 12 insertions(+), 5 deletions(-)\n\ndiff --git a/contrib/fast-import/import-tars.perl b/contrib/fast-import/import-tars.perl\nindex 6309d14..78e40d2 100755\n--- a/contrib/fast-import/import-tars.perl\n+++ b/contrib/fast-import/import-tars.perl\n@@ -82,10 +82,16 @@ foreach my $tar_file (@ARGV)\n \t\t$mtime = oct $mtime;\n \t\tnext if $typeflag == 5; # directory\n \n-\t\tprint FI \"blob\\n\", \"mark :$next_mark\\n\", \"data $size\\n\";\n-\t\twhile ($size > 0 && read(I, $_, 512) == 512) {\n-\t\t\tprint FI substr($_, 0, $size);\n-\t\t\t$size -= 512;\n+\t\tprint FI \"blob\\n\", \"mark :$next_mark\\n\";\n+\t\tif ($typeflag == 2) { # symbolic link\n+\t\t\tprint FI \"data \", length($linkname), \"\\n\", $linkname;\n+\t\t\t$mode = 0120000;\n+\t\t} else {\n+\t\t\tprint FI \"data $size\\n\";\n+\t\t\twhile ($size > 0 && read(I, $_, 512) == 512) {\n+\t\t\t\tprint FI substr($_, 0, $size);\n+\t\t\t\t$size -= 512;\n+\t\t\t}\n \t\t}\n \t\tprint FI \"\\n\";\n \n@@ -118,7 +124,8 @@ EOF\n \t{\n \t\tmy ($mark, $mode) = @{$files{$path}};\n \t\t$path =~ s,^([^/]+)/,, if $have_top_dir;\n-\t\tprintf FI \"M %o :%i %s\\n\", $mode & 0111 ? 0755 : 0644, $mark, $path;\n+\t\t$mode = $mode & 0111 ? 0755 : 0644 unless $mode == 0120000;\n+\t\tprintf FI \"M %o :%i %s\\n\", $mode, $mark, $path;\n \t}\n \tprint FI \"\\n\";\n \n-- \n1.6.3.284.g6fecc\n"}]}