X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;f=git-cvsimport.perl;h=ac74bc51b3197d06f13f588d6916400ac3e6fcf0;hb=a6e3768f641c2703266422aa05c05f1d01e886b2;hp=c5bf2d19cda6104f4fa9ade7c1407bb6ab8b5d1e;hpb=27e4dd8de76bdd60c88003e0f27cee8ad26c5cd6;p=git.git diff --git a/git-cvsimport.perl b/git-cvsimport.perl index c5bf2d19c..ac74bc51b 100755 --- a/git-cvsimport.perl +++ b/git-cvsimport.perl @@ -29,15 +29,18 @@ 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() { +sub usage(;$) { + my $msg = shift; + print(STDERR "Error: $msg\n") if $msg; print STDERR < '.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: #--------------------- @@ -651,7 +691,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 { @@ -824,6 +864,15 @@ while () { $state = 11; next; } + 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 + # due to server clock drift + print "skip patchset $patchset: $date too recent\n" if $opt_v; + $state = 11; + next; + } if (exists $ignorebranch{$branch}) { print STDERR "Skipping $branch\n"; $state = 11; @@ -920,6 +969,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.