X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=git-archimport.perl;h=0fcb156d14298e23658b6f495d7ed201b260834e;hb=723024d696a47556baac77700e47fef288691f37;hp=ada60ec240a8b3eb4ef6efea6b6223fc8523705f;hpb=67e31d6234c0332334d7aedd70b2f101bc010cf9;p=git.git diff --git a/git-archimport.perl b/git-archimport.perl index ada60ec24..0fcb156d1 100755 --- a/git-archimport.perl +++ b/git-archimport.perl @@ -95,6 +95,15 @@ $ENV{'TMPDIR'} = $opt_t if $opt_t; # $ENV{TMPDIR} will affect tempdir() calls: my $tmp = tempdir('git-archimport-XXXXXX', TMPDIR => 1, CLEANUP => 1); $opt_v && print "+ Using $tmp as temporary directory\n"; +unless (-d $git_dir) { # initial import needs empty directory + opendir DIR, '.' or die "Unable to open current directory: $!\n"; + while (my $entry = readdir DIR) { + $entry =~ /^\.\.?$/ or + die "Initial import needs an empty current working directory.\n" + } + closedir DIR +} + my %reachable = (); # Arch repositories we can access my %unreachable = (); # Arch repositories we can't access :< my @psets = (); # the collection @@ -226,7 +235,7 @@ my $import = 0; unless (-d $git_dir) { # initial import if ($psets[0]{type} eq 'i' || $psets[0]{type} eq 't') { print "Starting import from $psets[0]{id}\n"; - `git-init-db`; + `git-init`; die $! if $?; $import = 1; } else { @@ -544,7 +553,7 @@ foreach my $ps (@psets) { my $pid = open2(*READER, *WRITER,'git-commit-tree',$tree,@par) or die $!; - print WRITER $ps->{summary},"\n"; + print WRITER $ps->{summary},"\n\n"; print WRITER $ps->{message},"\n"; # make it easy to backtrack and figure out which Arch revision this was: @@ -746,7 +755,8 @@ sub parselog { $ps->{tag} = $1; $key = undef; } elsif (/^Summary:\s*(.*)$/ ) { - # summary can be multiline as long as it has a leading space + # summary can be multiline as long as it has a leading space. + # we squeeze it onto a single line, though. $ps->{summary} = [ $1 ]; $key = 'summary'; } elsif (/^Creator: (.*)\s*<([^\>]+)>/) { @@ -778,8 +788,18 @@ sub parselog { } } - # post-processing: - $ps->{summary} = join("\n",@{$ps->{summary}})."\n"; + # drop leading empty lines from the log message + while (@$log && $log->[0] eq '') { + shift @$log; + } + if (exists $ps->{summary} && @{$ps->{summary}}) { + $ps->{summary} = join(' ', @{$ps->{summary}}); + } + elsif (@$log == 0) { + $ps->{summary} = 'empty commit message'; + } else { + $ps->{summary} = $log->[0] . '...'; + } $ps->{message} = join("\n",@$log); # skip Arch control files, unescape pika-escaped files