[PATCH] [import-tars] fix importing of subversion tars

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



add a / between the prefix and name fields of the tar archive if prefix
is non-empty.

Signed-off-by: Uwe Kleine-König <ukleinek@xxxxxxxxxxxxxxxxxxxxxxxxxx>
---

> No, it still breaks, but in a new and interesting way: Now I _only_
> get the files with long pathnames!

I don't know exactly how standard-conformant it is not to include a
trailing / after prefix, but the subversion tar does it. 

I checked for a description of the tar format, the best thing I could
find is[1]:

	On USTAR format archives, the value of the prefix field, if
	non-null, is prefixed to the name field to allow names longer
	then 100 characters

But it's not specifying if an additional / is needed.


With this patch I get all the filenames right.

Now the common prefix subversion-1.4.3 is stripped, but probably that's
a feature.

BTW I shortly tested a tar that had an entry with prefix ending in / and
fast-import did the right thing.  So something more complicated as:

	if ($prefix and $prefix[-1] eq "/") ...

should not be needed.

Best regards
Uwe

[1] http://www.mkssoftware.com/docs/man4/tar.4.asp

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

diff --git a/contrib/fast-import/import-tars.perl b/contrib/fast-import/import-tars.perl
index 5585a8b..1842146 100755
--- a/contrib/fast-import/import-tars.perl
+++ b/contrib/fast-import/import-tars.perl
@@ -64,7 +64,12 @@ foreach my $tar_file (@ARGV)
 		}
 		print FI "\n";
 
-		my $path = "$prefix$name";
+		my $path;
+		if ($prefix) {
+			$path = "$prefix/$name";
+		} else {
+			$path = "$name";
+		}
 		$files{$path} = [$next_mark++, $mode];
 
 		$commit_time = $mtime if $mtime > $commit_time;
-- 
1.5.2.rc0.16.g0f57d

-- 
Uwe Kleine-König

exit vi, lesson IV:
Z Z

NB: may write current file
-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]