X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=git-cvsimport.perl;h=6c9fbfec3aae36d339cfeed66209a24e0ff03ae8;hb=191453f66449537da29e9fc156f7a981845ea8f6;hp=26867751d76f0a86bf406274bd916191d3a5bdbd;hpb=6211988f77ab20cc8705fb8c9ecb72ba166b80da;p=git.git diff --git a/git-cvsimport.perl b/git-cvsimport.perl index 26867751d..6c9fbfec3 100755 --- a/git-cvsimport.perl +++ b/git-cvsimport.perl @@ -29,7 +29,7 @@ use IPC::Open2; $SIG{'PIPE'}="IGNORE"; $ENV{'TZ'}="UTC"; -our ($opt_h,$opt_o,$opt_v,$opt_k,$opt_u,$opt_d,$opt_p,$opt_C,$opt_z,$opt_i,$opt_P, $opt_s,$opt_m,$opt_M,$opt_A,$opt_S,$opt_L); +our ($opt_h,$opt_o,$opt_v,$opt_k,$opt_u,$opt_d,$opt_p,$opt_C,$opt_z,$opt_i,$opt_P, $opt_s,$opt_m,$opt_M,$opt_A,$opt_S,$opt_L, $opt_a); my (%conv_author_name, %conv_author_email); sub usage() { @@ -37,7 +37,7 @@ sub usage() { Usage: ${\basename $0} # fetch/update GIT from CVS [-o branch-for-HEAD] [-h] [-v] [-d CVSROOT] [-A author-conv-file] [-p opts-for-cvsps] [-C GIT_repository] [-z fuzz] [-i] [-k] [-u] - [-s subst] [-m] [-M regex] [-S regex] [CVS_module] + [-s subst] [-a] [-m] [-M regex] [-S regex] [CVS_module] END exit(1); } @@ -85,7 +85,7 @@ sub write_author_info($) { close ($f); } -getopts("hivmkuo:d:p:C:z:s:M:P:A:S:L:") or usage(); +getopts("haivmkuo:d:p:C:z:s:M:P:A:S:L:") or usage(); usage if $opt_h; @ARGV <= 1 or usage(); @@ -105,6 +105,8 @@ if ($opt_d) { } $opt_o ||= "origin"; $opt_s ||= "-"; +$opt_a ||= 0; + my $git_tree = $opt_C; $git_tree ||= "."; @@ -518,7 +520,7 @@ $orig_git_index = $ENV{GIT_INDEX_FILE} if exists $ENV{GIT_INDEX_FILE}; my %index; # holds filenames of one index per branch unless (-d $git_dir) { - system("git-init-db"); + system("git-init"); die "Cannot init the GIT db at $git_tree: $?\n" if $?; system("git-read-tree"); die "Cannot init an empty tree: $?\n" if $?; @@ -573,9 +575,11 @@ if ($opt_A) { # run cvsps into a file unless we are getting # it passed as a file via $opt_P # +my $cvspsfile; unless ($opt_P) { print "Running cvsps...\n" if $opt_v; my $pid = open(CVSPS,"-|"); + my $cvspsfh; die "Cannot fork: $!\n" unless defined $pid; unless ($pid) { my @opt; @@ -588,18 +592,18 @@ unless ($opt_P) { exec("cvsps","--norc",@opt,"-u","-A",'--root',$opt_d,$cvs_tree); die "Could not start cvsps: $!\n"; } - my ($cvspsfh, $cvspsfile) = tempfile('gitXXXXXX', SUFFIX => '.cvsps', - DIR => File::Spec->tmpdir()); + ($cvspsfh, $cvspsfile) = tempfile('gitXXXXXX', SUFFIX => '.cvsps', + DIR => File::Spec->tmpdir()); while () { print $cvspsfh $_; } close CVSPS; close $cvspsfh; - $opt_P = $cvspsfile; +} else { + $cvspsfile = $opt_P; } - -open(CVS, "<$opt_P") or die $!; +open(CVS, "<$cvspsfile") or die $!; ## cvsps output: #--------------------- @@ -656,7 +660,7 @@ $ignorebranch{'#CVSPS_NO_BRANCH'} = 1; sub commit { if ($branch eq $opt_o && !$index{branch} && !get_headref($branch, $git_dir)) { # looks like an initial commit - # use the index primed by git-init-db + # use the index primed by git-init $ENV{GIT_INDEX_FILE} = '.git/index'; $index{$branch} = '.git/index'; } else { @@ -829,7 +833,7 @@ while () { $state = 11; next; } - if ( $starttime - 300 - (defined $opt_z ? $opt_z : 300) <= $date) { + if (!$opt_a && $starttime - 300 - (defined $opt_z ? $opt_z : 300) <= $date) { # skip if the commit is too recent # that the cvsps default fuzz is 300s, we give ourselves another # 300s just in case -- this also prevents skipping commits @@ -934,6 +938,10 @@ while () { } commit() if $branch and $state != 11; +unless ($opt_P) { + unlink($cvspsfile); +} + # The heuristic of repacking every 1024 commits can leave a # lot of unpacked data. If there is more than 1MB worth of # not-packed objects, repack once more.