git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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

From
Uwe Kleine-König <ukleinek@informatik.uni-freiburg.de>
Date
Apr 24, 2007, 11:51 UTC
Message-ID
<20070424115104.GA14986@informatik.uni-freiburg.de>
In-Reply-To
<20070424100924.GB23811@diana.vm.bytemark.co.uk>

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@informatik.uni-freiburg.de>
---
> 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
Previous: Karl HasselströmNext: Karl Hasselström
Message 5 of 8 in “Bug?: import-tars misbehaves on Subversion tarballs”
  1. Karl HasselströmApr 24, 2007
  2. Michael LoefflerApr 24, 2007
  3. Uwe Kleine-KönigApr 24, 2007
  4. Karl HasselströmApr 24, 2007
  5. [import-tars] fix importing of subversion tarsUwe Kleine-König, Apr 24, 2007
  6. Karl HasselströmApr 24, 2007
  7. Karl HasselströmApr 24, 2007
  8. Shawn O. PearceApr 24, 2007

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.