Merge lp:~naesten/bzr-fastimport/import-tars into lp:~bzr/bzr-fastimport/fastimport.dev

Proposed by Samuel Bronson on 2009-08-11
Status: Work in progress
Proposed branch: lp:~naesten/bzr-fastimport/import-tars
Merge into: lp:~bzr/bzr-fastimport/fastimport.dev
Diff against target: None lines
To merge this branch: bzr merge lp:~naesten/bzr-fastimport/import-tars
Reviewer Review Type Date Requested Status
Ian Clatworthy 2009-08-11 Needs Information on 2009-08-12
Review via email: mp+9984@code.launchpad.net
To post a comment you must log in.
Samuel Bronson (naesten) wrote :

Hey, Ian, this is the script that generated the fast-import streams that led me to most of the bugs I've reported in bzr-fastimport so far.

Ian Clatworthy (ian-clatworthy) wrote :

I'm happy to include this but I think we need to explicitly check the licensing of the original code to confirm it's OK for us to redistribute it.

We probably need something like exporters/import-tars.README (and exporters/import-tars.LICENSE?) acknowledging the original author and your tweaks to it. Perhaps explicitly mention yourself as the maintainer of the script as well, if that's the case.

review: Needs Information
Samuel Bronson (naesten) wrote :

> I'm happy to include this but I think we need to explicitly check the
> licensing of the original code to confirm it's OK for us to redistribute it.
>
> We probably need something like exporters/import-tars.README (and exporters
> /import-tars.LICENSE?) acknowledging the original author and your tweaks to
> it. Perhaps explicitly mention yourself as the maintainer of the script as
> well, if that's the case.

Well, the most specific license info for that file is in git's top-level COPYING, as far as I can tell, which says "GPL v2 only -- not v2.1, not v3, *v2*" (paraphrased).

The contributers shown by

naesten@hydrogen:~/hacking/git% ../tig/tig v1.6.3.3 -- contrib/fast-import/import-tars.perl

(the ../tig/ is because I added something to tig to make the dates narrower) are:

2009-06-17 14:49 Johannes Schindelin + import-tars: support symlinks
2009-03-20 10:57 Giuseppe Bilotta * import-tars: separate author from commit~
2007-05-16 12:43 Junio C Hamano M Merge branch 'maint'
2007-05-16 17:22 Johannes Schindelin │`* import-tars: Use the "Link indicator" ~
2007-05-10 14:48 Junio C Hamano M │ Merge branch 'maint'
2007-05-07 21:13 Shawn O. Pearce │`* Properly handle '0' filenames in impor~
2007-05-02 13:24 Shawn O. Pearce M │ Merge branch 'gfi-maint' into gfi-mast~
2007-05-01 23:42 Johannes Schindelin │`* Teach import-tars about GNU tar's @Lon~
2007-04-29 01:52 Junio C Hamano M │ Merge branch 'maint'
2007-04-29 00:31 Junio C Hamano │`* Fix import-tars fix.
2007-04-29 01:59 Johannes Schindelin │ * import-tars: be nice to wrong director~
2007-04-24 13:51 Uwe Kleine-König * │ fix importing of subversion tars
2007-02-14 17:03 Michael Loeffler *' Use gunzip -c over gzcat in import-tars~
2007-02-12 15:17 Michael Loeffler * import-tars: brown paper bag fix for fil~
2007-02-08 15:26 Shawn O. Pearce * tar archive frontend for fast-import.

And I'd be happy to try and fix any bugs people may find in the script.

Oh, btw, I'm going to my grandpa's house for a week (... say, ten minutes ago?), leaving my computer behind, so I probably won't be able to do much except maybe talk until I'm back.

Ian Clatworthy (ian-clatworthy) wrote :

Where is this up too now?

Samuel Bronson (naesten) wrote :

On Mon, Nov 23, 2009 at 2:08 AM, Ian Clatworthy
<email address hidden> wrote:
> Where is this up too now?

Uh, mostly forgotten, sorry :-(. Maybe I'll look at it over christmas break...

Unmerged revisions

201. By Samuel Bronson on 2009-08-11

Adapt import-tars.perl to output fast-import data to stdout.

(The version from git's contrib/ directory fed it directly to 'git
fast-import'!)

Also make the script executable.

200. By Samuel Bronson on 2009-08-11

Import git's contrib/fast-import/import-tars.perl (git version 1.6.3.3).

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== added file 'exporters/import-tars.perl'
2--- exporters/import-tars.perl 1970-01-01 00:00:00 +0000
3+++ exporters/import-tars.perl 2009-08-11 03:35:05 +0000
4@@ -0,0 +1,144 @@
5+#!/usr/bin/perl
6+
7+## tar archive frontend for git-fast-import
8+##
9+## For example:
10+##
11+## mkdir project; cd project; git init
12+## perl import-tars.perl *.tar.bz2 | git fast-import
13+## git whatchanged import-tars
14+##
15+
16+use strict;
17+die "usage: import-tars *.tar.{gz,bz2,Z}\n" unless @ARGV;
18+
19+my $branch_name = 'import-tars';
20+my $branch_ref = "refs/heads/$branch_name";
21+my $author_name = $ENV{'GIT_AUTHOR_NAME'} || 'T Ar Creator';
22+my $author_email = $ENV{'GIT_AUTHOR_EMAIL'} || 'tar@example.com';
23+my $committer_name = $ENV{'GIT_COMMITTER_NAME'} || `git config --get user.name`;
24+my $committer_email = $ENV{'GIT_COMMITTER_EMAIL'} || `git config --get user.email`;
25+
26+chomp($committer_name, $committer_email);
27+
28+*FI = *stdout;
29+
30+foreach my $tar_file (@ARGV)
31+{
32+ my $commit_time = time;
33+ $tar_file =~ m,([^/]+)$,;
34+ my $tar_name = $1;
35+
36+ if ($tar_name =~ s/\.(tar\.gz|tgz)$//) {
37+ open(I, '-|', 'gunzip', '-c', $tar_file)
38+ or die "Unable to gunzip -c $tar_file: $!\n";
39+ } elsif ($tar_name =~ s/\.(tar\.bz2|tbz2)$//) {
40+ open(I, '-|', 'bunzip2', '-c', $tar_file)
41+ or die "Unable to bunzip2 -c $tar_file: $!\n";
42+ } elsif ($tar_name =~ s/\.tar\.Z$//) {
43+ open(I, '-|', 'uncompress', '-c', $tar_file)
44+ or die "Unable to uncompress -c $tar_file: $!\n";
45+ } elsif ($tar_name =~ s/\.tar$//) {
46+ open(I, $tar_file) or die "Unable to open $tar_file: $!\n";
47+ } else {
48+ die "Unrecognized compression format: $tar_file\n";
49+ }
50+
51+ my $author_time = 0;
52+ my $next_mark = 1;
53+ my $have_top_dir = 1;
54+ my ($top_dir, %files);
55+
56+ while (read(I, $_, 512) == 512) {
57+ my ($name, $mode, $uid, $gid, $size, $mtime,
58+ $chksum, $typeflag, $linkname, $magic,
59+ $version, $uname, $gname, $devmajor, $devminor,
60+ $prefix) = unpack 'Z100 Z8 Z8 Z8 Z12 Z12
61+ Z8 Z1 Z100 Z6
62+ Z2 Z32 Z32 Z8 Z8 Z*', $_;
63+ last unless length($name);
64+ if ($name eq '././@LongLink') {
65+ # GNU tar extension
66+ if (read(I, $_, 512) != 512) {
67+ die ('Short archive');
68+ }
69+ $name = unpack 'Z257', $_;
70+ next unless $name;
71+
72+ my $dummy;
73+ if (read(I, $_, 512) != 512) {
74+ die ('Short archive');
75+ }
76+ ($dummy, $mode, $uid, $gid, $size, $mtime,
77+ $chksum, $typeflag, $linkname, $magic,
78+ $version, $uname, $gname, $devmajor, $devminor,
79+ $prefix) = unpack 'Z100 Z8 Z8 Z8 Z12 Z12
80+ Z8 Z1 Z100 Z6
81+ Z2 Z32 Z32 Z8 Z8 Z*', $_;
82+ }
83+ next if $name =~ m{/\z};
84+ $mode = oct $mode;
85+ $size = oct $size;
86+ $mtime = oct $mtime;
87+ next if $typeflag == 5; # directory
88+
89+ print FI "blob\n", "mark :$next_mark\n";
90+ if ($typeflag == 2) { # symbolic link
91+ print FI "data ", length($linkname), "\n", $linkname;
92+ $mode = 0120000;
93+ } else {
94+ print FI "data $size\n";
95+ while ($size > 0 && read(I, $_, 512) == 512) {
96+ print FI substr($_, 0, $size);
97+ $size -= 512;
98+ }
99+ }
100+ print FI "\n";
101+
102+ my $path;
103+ if ($prefix) {
104+ $path = "$prefix/$name";
105+ } else {
106+ $path = "$name";
107+ }
108+ $files{$path} = [$next_mark++, $mode];
109+
110+ $author_time = $mtime if $mtime > $author_time;
111+ $path =~ m,^([^/]+)/,;
112+ $top_dir = $1 unless $top_dir;
113+ $have_top_dir = 0 if $top_dir ne $1;
114+ }
115+
116+ print FI <<EOF;
117+commit $branch_ref
118+author $author_name <$author_email> $author_time +0000
119+committer $committer_name <$committer_email> $commit_time +0000
120+data <<END_OF_COMMIT_MESSAGE
121+Imported from $tar_file.
122+END_OF_COMMIT_MESSAGE
123+
124+deleteall
125+EOF
126+
127+ foreach my $path (keys %files)
128+ {
129+ my ($mark, $mode) = @{$files{$path}};
130+ $path =~ s,^([^/]+)/,, if $have_top_dir;
131+ $mode = $mode & 0111 ? 0755 : 0644 unless $mode == 0120000;
132+ printf FI "M %o :%i %s\n", $mode, $mark, $path;
133+ }
134+ print FI "\n";
135+
136+ print FI <<EOF;
137+tag $tar_name
138+from $branch_ref
139+tagger $author_name <$author_email> $author_time +0000
140+data <<END_OF_TAG_MESSAGE
141+Package $tar_name
142+END_OF_TAG_MESSAGE
143+
144+EOF
145+
146+ close I;
147+}
148+close FI;

Subscribers

People subscribed via source and target branches

to all changes: