Skip to content

Commit 8b8840e

Browse files
smurfixJunio C Hamano
authored andcommitted
[PATCH] cvsgit fixes: spaces in filenames and CVS server dialog woes
Problems found while importing dasher's CVS: * Allow spaces in filenames. * cvsps may create unnamed branches with revisions that don't really exist, which causes the CVS server to return something we haven't hitherto expected. * Report deleted files when being verbose. * Also, report the commit date. Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8c59890 commit 8b8840e

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

git-cvsimport-script

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,12 @@ sub _line {
294294
return $res;
295295
} elsif($line =~ s/^E //) {
296296
# print STDERR "S: $line\n";
297+
} elsif($line =~ /^Remove-entry /i) {
298+
$line = $self->readline(); # filename
299+
$line = $self->readline(); # OK
300+
chomp $line;
301+
die "Unknown: $line" if $line ne "ok";
302+
return -1;
297303
} else {
298304
die "Unknown: $line\n";
299305
}
@@ -561,7 +567,7 @@ my $commit = sub {
561567
or die "Error writing to git-commit-tree: $!\n";
562568
$pw->close();
563569

564-
print "Committed patch $patchset ($branch)\n" if $opt_v;
570+
print "Committed patch $patchset ($branch ".strftime("%Y-%m-%d %H:%M:%S",gmtime($date)).")\n" if $opt_v;
565571
chomp(my $cid = <$pr>);
566572
length($cid) == 40
567573
or die "Cannot get commit id ($cid): $!\n";
@@ -675,26 +681,32 @@ while(<CVS>) {
675681
$state = 9;
676682
} elsif($state == 8) {
677683
$logmsg .= "$_\n";
678-
} elsif($state == 9 and /^\s+(\S+):(INITIAL|\d+(?:\.\d+)+)->(\d+(?:\.\d+)+)\s*$/) {
684+
} elsif($state == 9 and /^\s+(.+?):(INITIAL|\d+(?:\.\d+)+)->(\d+(?:\.\d+)+)\s*$/) {
679685
# VERSION:1.96->1.96.2.1
680686
my $init = ($2 eq "INITIAL");
681687
my $fn = $1;
682688
my $rev = $3;
683689
$fn =~ s#^/+##;
684690
my ($tmpname, $size) = $cvs->file($fn,$rev);
685-
print "".($init ? "New" : "Update")." $fn: $size bytes.\n" if $opt_v;
686-
open my $F, '-|', "git-hash-object -w $tmpname"
687-
or die "Cannot create object: $!\n";
688-
my $sha = <$F>;
689-
chomp $sha;
690-
close $F;
691+
if($size == -1) {
692+
push(@old,$fn);
693+
print "Drop $fn\n" if $opt_v;
694+
} else {
695+
print "".($init ? "New" : "Update")." $fn: $size bytes\n" if $opt_v;
696+
open my $F, '-|', "git-hash-object -w $tmpname"
697+
or die "Cannot create object: $!\n";
698+
my $sha = <$F>;
699+
chomp $sha;
700+
close $F;
701+
my $mode = pmode($cvs->{'mode'});
702+
push(@new,[$mode, $sha, $fn]); # may be resurrected!
703+
}
691704
unlink($tmpname);
692-
my $mode = pmode($cvs->{'mode'});
693-
push(@new,[$mode, $sha, $fn]); # may be resurrected!
694-
} elsif($state == 9 and /^\s+(\S+):\d(?:\.\d+)+->(\d(?:\.\d+)+)\(DEAD\)\s*$/) {
705+
} elsif($state == 9 and /^\s+(.+?):\d(?:\.\d+)+->(\d(?:\.\d+)+)\(DEAD\)\s*$/) {
695706
my $fn = $1;
696707
$fn =~ s#^/+##;
697708
push(@old,$fn);
709+
print "Delete $fn\n" if $opt_v;
698710
} elsif($state == 9 and /^\s*$/) {
699711
$state = 10;
700712
} elsif(($state == 9 or $state == 10) and /^-+$/) {

0 commit comments

Comments
 (0)