{"thread":{"id":"7933","subject":"[PATCH] Teach import-tars about GNU tar's @LongLink extension.","startedAt":"2007-05-01T21:42:44Z","lastAt":"2007-05-01T21:42:44Z","messageCount":1,"participants":["Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"40856","messageId":"Pine.LNX.4.64.0705012335530.4010@racer.site","threadId":"7933","inReplyTo":null,"subject":"[PATCH] Teach import-tars about GNU tar's @LongLink extension.","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-05-01T21:42:44Z","receivedAt":"2007-05-01T21:42:44Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"\nThis extension allows GNU tar to process file names in excess of the 100 \ncharacters defined by the original tar standard. It does this by faking a \nfile, named '././@LongLink' containing the true file name, and then adding \nthe file with a truncated name. The idea is that tar without this \nextension will write out a file with the long file name, and write the \ncontents into a file with truncated name.\n\nUnfortunately, GNU tar does a lousy job at times. When truncating results \nin a _directory_ name, it will happily use _that_ as a truncated name for \nthe file.\n\nAn example where this actually happens is gcc-4.1.2, where the full path \nof the file WeThrowThisExceptionHelper.java truncates _exactly_ before the \nbasename. So, we have to support that ad-hoc extension.\n\nThis bug was noticed by Chris Riddoch on IRC.\n\nSigned-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>\n---\n\n\tDoes anybody know why they decided to limit the LongLink to 256 \n\tcharacters, when 512 bytes are wasted _anyway_?\n\n\tBTW I am a little too tired to find out why import-tars failed so \n\tbadly without this patch. It _should_ have behaved like tar\n\twithout that extension. Instead, it tripped completely, losing the \n\tcorrect block boundary.\n\n contrib/fast-import/import-tars.perl |   19 +++++++++++++++++++\n 1 files changed, 19 insertions(+), 0 deletions(-)\n\ndiff --git a/contrib/fast-import/import-tars.perl b/contrib/fast-import/import-tars.perl\nindex d2363a4..a43b2c5 100755\n--- a/contrib/fast-import/import-tars.perl\n+++ b/contrib/fast-import/import-tars.perl\n@@ -52,6 +52,25 @@ foreach my $tar_file (@ARGV)\n \t\t\tZ8 Z1 Z100 Z6\n \t\t\tZ2 Z32 Z32 Z8 Z8 Z*', $_;\n \t\tlast unless $name;\n+\t\tif ($name eq '././@LongLink') {\n+\t\t\t# GNU tar extension\n+\t\t\tif (read(I, $_, 512) != 512) {\n+\t\t\t\tdie ('Short archive');\n+\t\t\t}\n+\t\t\t$name = unpack 'Z257', $_;\n+\t\t\tnext unless $name;\n+\n+\t\t\tmy $dummy;\n+\t\t\tif (read(I, $_, 512) != 512) {\n+\t\t\t\tdie ('Short archive');\n+\t\t\t}\n+\t\t\t($dummy, $mode, $uid, $gid, $size, $mtime,\n+\t\t\t$chksum, $typeflag, $linkname, $magic,\n+\t\t\t$version, $uname, $gname, $devmajor, $devminor,\n+\t\t\t$prefix) = unpack 'Z100 Z8 Z8 Z8 Z12 Z12\n+\t\t\tZ8 Z1 Z100 Z6\n+\t\t\tZ2 Z32 Z32 Z8 Z8 Z*', $_;\n+\t\t}\n \t\tnext if $name =~ m{/\\z};\n \t\t$mode = oct $mode;\n \t\t$size = oct $size;\n-- \n1.5.2.rc1.2428.g1b62-dirty\n"}]}