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

Re: [PATCH] import-tars: use Archive::Tar instead of unpack()

From
Shawn O. Pearce <spearce@spearce.org>
Date
Feb 12, 2007, 17:28 UTC
Message-ID
<20070212172848.GC29621@spearce.org>
In-Reply-To
<1171289831.629.6.camel@ibook.zvpunry.de>
Michael Loeffler <zvpunry@zvpunry.de> wrote:
> This version does no longer support bzip2 or compress which will be fixed in
> an amend. I did this patch to solve 2 problems. Maybe I do another patch with
> GetoptLong and bzip2/compress support.
bzip2 and compress are popular formats applied to tars.
 
Show 8 quoted lines
> @@ -10,6 +10,10 @@
>  ##
>  
>  use strict;
> +use Archive::Tar;
> +use Archive::Tar::File;
> +use Archive::Tar::Constant;
> +

I did not apply this hunk. Not everyone has Archive::Tar installed. But then again, not everyone will use this example program either. I'm debating it. Archive::Tar's parser will certainly be much more robust than the one I hand-crafted. It might also let us deal with symlinks. ;)

I would considering applying something like this if it would also support at least bz2. This is an example program meant to teach people how to use fast-import, and maybe also to help someone who wants to quickly import one or more .tar.gz for use with git-grep. Requiring Archive::Tar here is not the end of Git as we know it. :)

Show 11 quoted lines
> @@ -83,10 +64,8 @@ EOF
>  	foreach my $path (keys %files)
>  	{
>  		my ($mark, $mode) = @{$files{$path}};
> -		my $git_mode = 0644;
> -		$git_mode |= 0700 if $mode & 0111;
>  		$path =~ s,^([^/]+)/,, if $have_top_dir;
> -		printf FI "M %o :%i %s\n", $git_mode, $mark, $path;
> +		printf FI "M %o :%i %s\n", $mode & 0111 ? 0755 : 0644, $mark, $path;
>  	}
>  	print FI "\n";

This hunk is completely unrelated to the Archive::Tar rewrite. It also fixes a rather embarrassing bug on my part; I should have been able to get the mode right! :-)

I've applied this hunk (and only this hunk) to my fastimport tree and pushed it out.

-- 
Shawn.
Previous: Johannes SchindelinNext: Michael Loeffler
Message 3 of 7 in “import-tars: use Archive::Tar instead of unpack()”
  1. import-tars: use Archive::Tar instead of unpack()Michael Loeffler, Feb 12, 2007
  2. Johannes SchindelinFeb 12, 2007
  3. Shawn O. PearceFeb 12, 2007
  4. Michael LoefflerFeb 14, 2007
  5. Shawn O. PearceFeb 15, 2007
  6. Karl HasselströmApr 24, 2007
  7. Sam VilainApr 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.