@matheusbsbs / matheus-bagliano / commits / 775477aa1d
Fork 0

Teach import-tars about GNU tar's @LongLink extension.

This extension allows GNU tar to process file names in excess of the 100 characters defined by the original tar standard. It does this by faking a file, named '././@LongLink' containing the true file name, and then adding the file with a truncated name. The idea is that tar without this extension will write out a file with the long file name, and write the contents into a file with truncated name. Unfortunately, GNU tar does a lousy job at times. When truncating results in a _directory_ name, it will happily use _that_ as a truncated name for the file. An example where this actually happens is gcc-4.1.2, where the full path of the file WeThrowThisExceptionHelper.java truncates _exactly_ before the basename. So, we have to support that ad-hoc extension. This bug was noticed by Chris Riddoch on IRC. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>

Johannes Schindelin committed May 1, 2007 at 23:42 UTC 775477aa1da94cb9fb9b9afdc217231a0cd42ac1
1 file changed +19
contrib/fast-import/import-tars.perl
+19
@@ -52,6 +52,25 @@ foreach my $tar_file (@ARGV)
52 Z8 Z1 Z100 Z6
53 Z2 Z32 Z32 Z8 Z8 Z*', $_;
54 last unless $name;
55 + if ($name eq '././@LongLink') {
56 + # GNU tar extension
57 + if (read(I, $_, 512) != 512) {
58 + die ('Short archive');
59 + }
60 + $name = unpack 'Z257', $_;
61 + next unless $name;
62 +
63 + my $dummy;
64 + if (read(I, $_, 512) != 512) {
65 + die ('Short archive');
66 + }
67 + ($dummy, $mode, $uid, $gid, $size, $mtime,
68 + $chksum, $typeflag, $linkname, $magic,
69 + $version, $uname, $gname, $devmajor, $devminor,
70 + $prefix) = unpack 'Z100 Z8 Z8 Z8 Z12 Z12
71 + Z8 Z1 Z100 Z6
72 + Z2 Z32 Z32 Z8 Z8 Z*', $_;
73 + }
74 next if $name =~ m{/\z};
75 $mode = oct $mode;
76 $size = oct $size;