Git development
 help / color / mirror / Atom feed
From: Johannes Schindelin <Johannes.Schindelin@gmx.de>
To: git@vger.kernel.org, spearce@spearce.org
Subject: [PATCH] Teach import-tars about GNU tar's @LongLink extension.
Date: Tue, 1 May 2007 23:42:44 +0200 (CEST)	[thread overview]
Message-ID: <Pine.LNX.4.64.0705012335530.4010@racer.site> (raw)


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>
---

	Does anybody know why they decided to limit the LongLink to 256 
	characters, when 512 bytes are wasted _anyway_?

	BTW I am a little too tired to find out why import-tars failed so 
	badly without this patch. It _should_ have behaved like tar
	without that extension. Instead, it tripped completely, losing the 
	correct block boundary.

 contrib/fast-import/import-tars.perl |   19 +++++++++++++++++++
 1 files changed, 19 insertions(+), 0 deletions(-)

diff --git a/contrib/fast-import/import-tars.perl b/contrib/fast-import/import-tars.perl
index d2363a4..a43b2c5 100755
--- a/contrib/fast-import/import-tars.perl
+++ b/contrib/fast-import/import-tars.perl
@@ -52,6 +52,25 @@ foreach my $tar_file (@ARGV)
 			Z8 Z1 Z100 Z6
 			Z2 Z32 Z32 Z8 Z8 Z*', $_;
 		last unless $name;
+		if ($name eq '././@LongLink') {
+			# GNU tar extension
+			if (read(I, $_, 512) != 512) {
+				die ('Short archive');
+			}
+			$name = unpack 'Z257', $_;
+			next unless $name;
+
+			my $dummy;
+			if (read(I, $_, 512) != 512) {
+				die ('Short archive');
+			}
+			($dummy, $mode, $uid, $gid, $size, $mtime,
+			$chksum, $typeflag, $linkname, $magic,
+			$version, $uname, $gname, $devmajor, $devminor,
+			$prefix) = unpack 'Z100 Z8 Z8 Z8 Z12 Z12
+			Z8 Z1 Z100 Z6
+			Z2 Z32 Z32 Z8 Z8 Z*', $_;
+		}
 		next if $name =~ m{/\z};
 		$mode = oct $mode;
 		$size = oct $size;
-- 
1.5.2.rc1.2428.g1b62-dirty

                 reply	other threads:[~2007-05-01 21:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.64.0705012335530.4010@racer.site \
    --to=johannes.schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=spearce@spearce.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox