From 590dd4bfd25b3c7592004258384f7541d9315712 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Thu, 8 Feb 2007 15:26:01 -0500 Subject: tar archive frontend for fast-import. This is an example fast-import frontend, in less than 100 lines of Perl. It accepts one or more tar archives on the command line, passes them through gzcat/bzcat/zcat if necessary, parses out the individual file headers and feeds all contained data to fast-import. No temporary files are involved. Each tar is treated as one commit, with the commit timestamp coming from the oldest file modification date found within the tar. Each tar is also tagged with an annotated tag, using the basename of the tar file as the name of the tag. Currently symbolic links and hard links are not handled by the importer. The file checksums are also not verified. Signed-off-by: Shawn O. Pearce --- contrib/fast-import/import-tars.perl | 105 +++++++++++++++++++++++++++++++++++ 1 file changed, 105 insertions(+) create mode 100755 contrib/fast-import/import-tars.perl (limited to 'contrib/fast-import/import-tars.perl') diff --git a/contrib/fast-import/import-tars.perl b/contrib/fast-import/import-tars.perl new file mode 100755 index 0000000000..26c42c9780 --- /dev/null +++ b/contrib/fast-import/import-tars.perl @@ -0,0 +1,105 @@ +#!/usr/bin/perl + +## tar archive frontend for git-fast-import +## +## For example: +## +## mkdir project; cd project; git init +## perl import-tars.perl *.tar.bz2 +## git whatchanged import-tars +## + +use strict; +die "usage: import-tars *.tar.{gz,bz2,Z}\n" unless @ARGV; + +my $branch_name = 'import-tars'; +my $branch_ref = "refs/heads/$branch_name"; +my $committer_name = 'T Ar Creator'; +my $committer_email = 'tar@example.com'; + +open(FI, '|-', 'git', 'fast-import', '--quiet') + or die "Unable to start git fast-import: $!\n"; +foreach my $tar_file (@ARGV) +{ + $tar_file =~ m,([^/]+)$,; + my $tar_name = $1; + + if ($tar_name =~ s/\.(tar\.gz|tgz)$//) { + open(I, '-|', 'gzcat', $tar_file) or die "Unable to gzcat $tar_file: $!\n"; + } elsif ($tar_name =~ s/\.(tar\.bz2|tbz2)$//) { + open(I, '-|', 'bzcat', $tar_file) or die "Unable to bzcat $tar_file: $!\n"; + } elsif ($tar_name =~ s/\.tar\.Z$//) { + open(I, '-|', 'zcat', $tar_file) or die "Unable to zcat $tar_file: $!\n"; + } elsif ($tar_name =~ s/\.tar$//) { + open(I, $tar_file) or die "Unable to open $tar_file: $!\n"; + } else { + die "Unrecognized compression format: $tar_file\n"; + } + + my $commit_time = 0; + my $next_mark = 1; + my $have_top_dir = 1; + my ($top_dir, %files); + + while (read(I, $_, 512) == 512) { + my ($name, $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*', $_; + last unless $name; + $mode = oct $mode; + $size = oct $size; + $mtime = oct $mtime; + next if $mode & 0040000; + + print FI "blob\n", "mark :$next_mark\n", "data $size\n"; + while ($size > 0 && read(I, $_, 512) == 512) { + print FI substr($_, 0, $size); + $size -= 512; + } + print FI "\n"; + + my $path = "$prefix$name"; + $files{$path} = [$next_mark++, $mode]; + + $commit_time = $mtime if $mtime > $commit_time; + $path =~ m,^([^/]+)/,; + $top_dir = $1 unless $top_dir; + $have_top_dir = 0 if $top_dir ne $1; + } + + print FI < $commit_time +0000 +data < $commit_time +0000 +data < Date: Mon, 12 Feb 2007 15:17:11 +0100 Subject: import-tars: brown paper bag fix for file mode. There is a bug with this $git_mode variable which should be 0644 or 0755, but nothing else I think. Signed-off-by: Michael Loeffler Signed-off-by: Shawn O. Pearce --- contrib/fast-import/import-tars.perl | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'contrib/fast-import/import-tars.perl') diff --git a/contrib/fast-import/import-tars.perl b/contrib/fast-import/import-tars.perl index 26c42c9780..990c9e70b2 100755 --- a/contrib/fast-import/import-tars.perl +++ b/contrib/fast-import/import-tars.perl @@ -83,10 +83,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"; -- cgit v1.2.3 From c750da256a54f189de28d3deb054328d67f9b9be Mon Sep 17 00:00:00 2001 From: Michael Loeffler Date: Wed, 14 Feb 2007 17:03:12 +0100 Subject: Use gunzip -c over gzcat in import-tars example. Not everyone has gzcat or bzcat installed on their system, but gunzip -c and bunzip2 -c perform the same task and are available if the user has installed gzip support or bzip2 support. Signed-off-by: Michael Loeffler Signed-off-by: Shawn O. Pearce --- contrib/fast-import/import-tars.perl | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'contrib/fast-import/import-tars.perl') diff --git a/contrib/fast-import/import-tars.perl b/contrib/fast-import/import-tars.perl index 990c9e70b2..5585a8b2c5 100755 --- a/contrib/fast-import/import-tars.perl +++ b/contrib/fast-import/import-tars.perl @@ -25,11 +25,14 @@ foreach my $tar_file (@ARGV) my $tar_name = $1; if ($tar_name =~ s/\.(tar\.gz|tgz)$//) { - open(I, '-|', 'gzcat', $tar_file) or die "Unable to gzcat $tar_file: $!\n"; + open(I, '-|', 'gunzip', '-c', $tar_file) + or die "Unable to gunzip -c $tar_file: $!\n"; } elsif ($tar_name =~ s/\.(tar\.bz2|tbz2)$//) { - open(I, '-|', 'bzcat', $tar_file) or die "Unable to bzcat $tar_file: $!\n"; + open(I, '-|', 'bunzip2', '-c', $tar_file) + or die "Unable to bunzip2 -c $tar_file: $!\n"; } elsif ($tar_name =~ s/\.tar\.Z$//) { - open(I, '-|', 'zcat', $tar_file) or die "Unable to zcat $tar_file: $!\n"; + open(I, '-|', 'uncompress', '-c', $tar_file) + or die "Unable to uncompress -c $tar_file: $!\n"; } elsif ($tar_name =~ s/\.tar$//) { open(I, $tar_file) or die "Unable to open $tar_file: $!\n"; } else { -- cgit v1.2.3 From 46f6178a3f4e7a5bf8b47da0f3cc5c998d907ce8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= Date: Tue, 24 Apr 2007 13:51:04 +0200 Subject: fix importing of subversion tars MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit add a / between the prefix and name fields of the tar archive if prefix is non-empty. Signed-off-by: Uwe Kleine-König Signed-off-by: Shawn O. Pearce --- contrib/fast-import/import-tars.perl | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'contrib/fast-import/import-tars.perl') diff --git a/contrib/fast-import/import-tars.perl b/contrib/fast-import/import-tars.perl index 5585a8b2c5..184214689d 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; -- cgit v1.2.3 From 87859f34434dda61cabb03447efd1dd2fe7ebac7 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sun, 29 Apr 2007 01:59:47 +0200 Subject: import-tars: be nice to wrong directory modes Some tars seem to have modes 0755 for directories, not 01000755. Do not generate an empty object for them, but ignore them. Noticed by riddochc on IRC. Signed-off-by: Johannes Schindelin Signed-off-by: Shawn O. Pearce --- contrib/fast-import/import-tars.perl | 1 + 1 file changed, 1 insertion(+) (limited to 'contrib/fast-import/import-tars.perl') diff --git a/contrib/fast-import/import-tars.perl b/contrib/fast-import/import-tars.perl index 5585a8b2c5..e84647770a 100755 --- a/contrib/fast-import/import-tars.perl +++ b/contrib/fast-import/import-tars.perl @@ -52,6 +52,7 @@ foreach my $tar_file (@ARGV) Z8 Z1 Z100 Z6 Z2 Z32 Z32 Z8 Z8 Z*', $_; last unless $name; + next if $name =~ '/$'; $mode = oct $mode; $size = oct $size; $mtime = oct $mtime; -- cgit v1.2.3 From d0c32b63394992f8dd083a4f2f380ab190dbb2ca Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sun, 29 Apr 2007 00:31:14 -0700 Subject: Fix import-tars fix. This heeds advice from our resident Perl expert to make sure the script is not confused with a string that ends with /\n Signed-off-by: Junio C Hamano --- contrib/fast-import/import-tars.perl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'contrib/fast-import/import-tars.perl') diff --git a/contrib/fast-import/import-tars.perl b/contrib/fast-import/import-tars.perl index e84647770a..82a90429c8 100755 --- a/contrib/fast-import/import-tars.perl +++ b/contrib/fast-import/import-tars.perl @@ -52,7 +52,7 @@ foreach my $tar_file (@ARGV) Z8 Z1 Z100 Z6 Z2 Z32 Z32 Z8 Z8 Z*', $_; last unless $name; - next if $name =~ '/$'; + next if $name =~ m{/\z}; $mode = oct $mode; $size = oct $size; $mtime = oct $mtime; -- cgit v1.2.3 From 775477aa1da94cb9fb9b9afdc217231a0cd42ac1 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Tue, 1 May 2007 23:42:44 +0200 Subject: 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 Signed-off-by: Shawn O. Pearce --- contrib/fast-import/import-tars.perl | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'contrib/fast-import/import-tars.perl') diff --git a/contrib/fast-import/import-tars.perl b/contrib/fast-import/import-tars.perl index 82a90429c8..e46492048c 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; -- cgit v1.2.3 From d966e6aa66d397908b4fbf69cef2e2da88737321 Mon Sep 17 00:00:00 2001 From: "Shawn O. Pearce" Date: Mon, 7 May 2007 21:13:40 -0400 Subject: Properly handle '0' filenames in import-tars Randal L. Schwartz pointed out multiple times that we should be testing the length of the name string here, not if it is "true". The problem is the string '0' is actually false in Perl when we try to evaluate it in this context, as '0' is 0 numerically and the number 0 is treated as a false value. This would cause us to break out of the import loop early if anyone had a file or directory named "0". Signed-off-by: Shawn O. Pearce --- contrib/fast-import/import-tars.perl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'contrib/fast-import/import-tars.perl') diff --git a/contrib/fast-import/import-tars.perl b/contrib/fast-import/import-tars.perl index e46492048c..f0b9a43abd 100755 --- a/contrib/fast-import/import-tars.perl +++ b/contrib/fast-import/import-tars.perl @@ -51,7 +51,7 @@ foreach my $tar_file (@ARGV) $prefix) = unpack 'Z100 Z8 Z8 Z8 Z12 Z12 Z8 Z1 Z100 Z6 Z2 Z32 Z32 Z8 Z8 Z*', $_; - last unless $name; + last unless length($name); if ($name eq '././@LongLink') { # GNU tar extension if (read(I, $_, 512) != 512) { -- cgit v1.2.3 From df8cfac815a1fae75afd20a86beb194d9d947971 Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Wed, 16 May 2007 17:22:26 +0100 Subject: import-tars: Use the "Link indicator" to identify directories Earlier, we used the mode to determine if a name was associated with a directory. This fails, since some tar programs do not set the mode correctly. However, the link indicator _has_ to be set correctly. Noticed by Chris Riddoch. Signed-off-by: Johannes Schindelin Acked-by: Junio C Hamano Signed-off-by: Shawn O. Pearce --- contrib/fast-import/import-tars.perl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'contrib/fast-import/import-tars.perl') diff --git a/contrib/fast-import/import-tars.perl b/contrib/fast-import/import-tars.perl index f0b9a43abd..5bfd205225 100755 --- a/contrib/fast-import/import-tars.perl +++ b/contrib/fast-import/import-tars.perl @@ -75,7 +75,7 @@ foreach my $tar_file (@ARGV) $mode = oct $mode; $size = oct $size; $mtime = oct $mtime; - next if $mode & 0040000; + next if $typeflag == 5; # directory print FI "blob\n", "mark :$next_mark\n", "data $size\n"; while ($size > 0 && read(I, $_, 512) == 512) { -- cgit v1.2.3 From 6872f606d9bc9a0ab0b3252bd4175af7732b6135 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Fri, 20 Mar 2009 10:57:50 +0100 Subject: import-tars: separate author from committer The import-tars script is typically employed to (re)create the past history of a project from stored tars. Although assigning authorship in these cases can be a somewhat arbitrary process, it makes sense to set the author to whoever created the tars in the first place (if it's known), and (s)he can in general be different from the committer (whoever is running the script). Implement this by having separate author and committer data, making them settable from the usual GIT_* environment variables. Acked-by: Shawn O. Pearce Signed-off-by: Junio C Hamano --- contrib/fast-import/import-tars.perl | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'contrib/fast-import/import-tars.perl') diff --git a/contrib/fast-import/import-tars.perl b/contrib/fast-import/import-tars.perl index 23aeb257b9..6309d146e7 100755 --- a/contrib/fast-import/import-tars.perl +++ b/contrib/fast-import/import-tars.perl @@ -14,13 +14,18 @@ die "usage: import-tars *.tar.{gz,bz2,Z}\n" unless @ARGV; my $branch_name = 'import-tars'; my $branch_ref = "refs/heads/$branch_name"; -my $committer_name = 'T Ar Creator'; -my $committer_email = 'tar@example.com'; +my $author_name = $ENV{'GIT_AUTHOR_NAME'} || 'T Ar Creator'; +my $author_email = $ENV{'GIT_AUTHOR_EMAIL'} || 'tar@example.com'; +my $committer_name = $ENV{'GIT_COMMITTER_NAME'} || `git config --get user.name`; +my $committer_email = $ENV{'GIT_COMMITTER_EMAIL'} || `git config --get user.email`; + +chomp($committer_name, $committer_email); open(FI, '|-', 'git', 'fast-import', '--quiet') or die "Unable to start git fast-import: $!\n"; foreach my $tar_file (@ARGV) { + my $commit_time = time; $tar_file =~ m,([^/]+)$,; my $tar_name = $1; @@ -39,7 +44,7 @@ foreach my $tar_file (@ARGV) die "Unrecognized compression format: $tar_file\n"; } - my $commit_time = 0; + my $author_time = 0; my $next_mark = 1; my $have_top_dir = 1; my ($top_dir, %files); @@ -92,7 +97,7 @@ foreach my $tar_file (@ARGV) } $files{$path} = [$next_mark++, $mode]; - $commit_time = $mtime if $mtime > $commit_time; + $author_time = $mtime if $mtime > $author_time; $path =~ m,^([^/]+)/,; $top_dir = $1 unless $top_dir; $have_top_dir = 0 if $top_dir ne $1; @@ -100,6 +105,7 @@ foreach my $tar_file (@ARGV) print FI < $author_time +0000 committer $committer_name <$committer_email> $commit_time +0000 data < $commit_time +0000 +tagger $author_name <$author_email> $author_time +0000 data < Date: Wed, 17 Jun 2009 14:49:39 +0200 Subject: import-tars: support symlinks Without this patch, symbolic links are turned into empty files. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- contrib/fast-import/import-tars.perl | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'contrib/fast-import/import-tars.perl') diff --git a/contrib/fast-import/import-tars.perl b/contrib/fast-import/import-tars.perl index 6309d146e7..78e40d2a13 100755 --- a/contrib/fast-import/import-tars.perl +++ b/contrib/fast-import/import-tars.perl @@ -82,10 +82,16 @@ foreach my $tar_file (@ARGV) $mtime = oct $mtime; next if $typeflag == 5; # directory - print FI "blob\n", "mark :$next_mark\n", "data $size\n"; - while ($size > 0 && read(I, $_, 512) == 512) { - print FI substr($_, 0, $size); - $size -= 512; + print FI "blob\n", "mark :$next_mark\n"; + if ($typeflag == 2) { # symbolic link + print FI "data ", length($linkname), "\n", $linkname; + $mode = 0120000; + } else { + print FI "data $size\n"; + while ($size > 0 && read(I, $_, 512) == 512) { + print FI substr($_, 0, $size); + $size -= 512; + } } print FI "\n"; @@ -118,7 +124,8 @@ EOF { my ($mark, $mode) = @{$files{$path}}; $path =~ s,^([^/]+)/,, if $have_top_dir; - printf FI "M %o :%i %s\n", $mode & 0111 ? 0755 : 0644, $mark, $path; + $mode = $mode & 0111 ? 0755 : 0644 unless $mode == 0120000; + printf FI "M %o :%i %s\n", $mode, $mark, $path; } print FI "\n"; -- cgit v1.2.3 From 7e787953fb89fbe403060585f7c39f0c75f29318 Mon Sep 17 00:00:00 2001 From: Peter Krefting Date: Thu, 3 Sep 2009 13:15:00 +0100 Subject: import-tars: Allow per-tar author and commit message. If the "--metainfo=" option is given on the command line, a file called "." will be used to create the commit message for "", instead of using "Imported from filename.tar". The author and committer of the tar ball can also be overridden by embedding an "Author:" or "Committer:" header in the metainfo file. Signed-off-by: Peter Krefting Signed-off-by: Junio C Hamano --- contrib/fast-import/import-tars.perl | 50 +++++++++++++++++++++++++++++++++--- 1 file changed, 46 insertions(+), 4 deletions(-) (limited to 'contrib/fast-import/import-tars.perl') diff --git a/contrib/fast-import/import-tars.perl b/contrib/fast-import/import-tars.perl index 78e40d2a13..a909716682 100755 --- a/contrib/fast-import/import-tars.perl +++ b/contrib/fast-import/import-tars.perl @@ -8,9 +8,20 @@ ## perl import-tars.perl *.tar.bz2 ## git whatchanged import-tars ## +## Use --metainfo to specify the extension for a meta data file, where +## import-tars can read the commit message and optionally author and +## committer information. +## +## echo 'This is the commit message' > myfile.tar.bz2.msg +## perl import-tars.perl --metainfo=msg myfile.tar.bz2 use strict; -die "usage: import-tars *.tar.{gz,bz2,Z}\n" unless @ARGV; +use Getopt::Long; + +my $metaext = ''; + +die "usage: import-tars [--metainfo=extension] *.tar.{gz,bz2,Z}\n" + unless GetOptions('metainfo=s' => \$metaext) && @ARGV; my $branch_name = 'import-tars'; my $branch_ref = "refs/heads/$branch_name"; @@ -109,12 +120,43 @@ foreach my $tar_file (@ARGV) $have_top_dir = 0 if $top_dir ne $1; } + my $commit_msg = "Imported from $tar_file."; + my $this_committer_name = $committer_name; + my $this_committer_email = $committer_email; + my $this_author_name = $author_name; + my $this_author_email = $author_email; + if ($metaext ne '') { + # Optionally read a commit message from .msg + # Add a line on the form "Committer: name " to override + # the committer and "Author: name " to override the + # author for this tar ball. + if (open MSG, '<', "${tar_file}.${metaext}") { + my $header_done = 0; + $commit_msg = ''; + while () { + if (!$header_done && /^Committer:\s+([^<>]*)\s+<(.*)>\s*$/i) { + $this_committer_name = $1; + $this_committer_email = $2; + } elsif (!$header_done && /^Author:\s+([^<>]*)\s+<(.*)>\s*$/i) { + $this_author_name = $1; + $this_author_email = $2; + } elsif (!$header_done && /^$/ { # empty line ends header. + $header_done = 1; + } else { + $commit_msg .= $_; + $header_done = 1; + } + } + close MSG; + } + } + print FI < $author_time +0000 -committer $committer_name <$committer_email> $commit_time +0000 +author $this_author_name <$this_author_email> $author_time +0000 +committer $this_committer_name <$this_committer_email> $commit_time +0000 data < Date: Fri, 9 Oct 2009 14:08:31 +0200 Subject: import-tars: Add missing closing bracket This fixes an obvious syntax error that snuck in commit 7e787953: syntax error at /home/ingmar/bin//git-import-tars line 143, near "/^$/ { " syntax error at /home/ingmar/bin//git-import-tars line 145, near "} else" syntax error at /home/ingmar/bin//git-import-tars line 152, near "}" Signed-off-by: Ingmar Vanhassel Acked-and-Tested-by: Peter Krefting Signed-off-by: Junio C Hamano --- contrib/fast-import/import-tars.perl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'contrib/fast-import/import-tars.perl') diff --git a/contrib/fast-import/import-tars.perl b/contrib/fast-import/import-tars.perl index a909716682..7001862bfd 100755 --- a/contrib/fast-import/import-tars.perl +++ b/contrib/fast-import/import-tars.perl @@ -140,7 +140,7 @@ foreach my $tar_file (@ARGV) } elsif (!$header_done && /^Author:\s+([^<>]*)\s+<(.*)>\s*$/i) { $this_author_name = $1; $this_author_email = $2; - } elsif (!$header_done && /^$/ { # empty line ends header. + } elsif (!$header_done && /^$/) { # empty line ends header. $header_done = 1; } else { $commit_msg .= $_; -- cgit v1.2.3 From 2a94552887ecbaa8b848a92eb607e032d77c8a2c Mon Sep 17 00:00:00 2001 From: Ingmar Vanhassel Date: Tue, 20 Oct 2009 12:29:32 +0200 Subject: import-tars: Add support for tarballs compressed with lzma, xz Also handle the extensions .tlz and .txz, aliases for .tar.lzma and .tar.xz respectively. Signed-off-by: Ingmar Vanhassel Liked-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- contrib/fast-import/import-tars.perl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'contrib/fast-import/import-tars.perl') diff --git a/contrib/fast-import/import-tars.perl b/contrib/fast-import/import-tars.perl index 7001862bfd..95438e1ed4 100755 --- a/contrib/fast-import/import-tars.perl +++ b/contrib/fast-import/import-tars.perl @@ -20,7 +20,7 @@ use Getopt::Long; my $metaext = ''; -die "usage: import-tars [--metainfo=extension] *.tar.{gz,bz2,Z}\n" +die "usage: import-tars [--metainfo=extension] *.tar.{gz,bz2,lzma,xz,Z}\n" unless GetOptions('metainfo=s' => \$metaext) && @ARGV; my $branch_name = 'import-tars'; @@ -49,6 +49,9 @@ foreach my $tar_file (@ARGV) } elsif ($tar_name =~ s/\.tar\.Z$//) { open(I, '-|', 'uncompress', '-c', $tar_file) or die "Unable to uncompress -c $tar_file: $!\n"; + } elsif ($tar_name =~ s/\.(tar\.(lzma|xz)|(tlz|txz))$//) { + open(I, '-|', 'xz', '-dc', $tar_file) + or die "Unable to xz -dc $tar_file: $!\n"; } elsif ($tar_name =~ s/\.tar$//) { open(I, $tar_file) or die "Unable to open $tar_file: $!\n"; } else { -- cgit v1.2.3