cvsimport: use git-update-index --index-info

This should reduce the number of git-update-index forks required per
commit. We now do adds/removes in one call, and we are no longer forced to
deal with argv limitations.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <junkio@cox.net>
This commit is contained in:
Jeff King 2006-05-23 03:27:45 -04:00 committed by Junio C Hamano
parent 443f8338b9
commit 6a1871e174

View File

@ -565,29 +565,19 @@ my($patchset,$date,$author_name,$author_email,$branch,$ancestor,$tag,$logmsg);
my(@old,@new,@skipped); my(@old,@new,@skipped);
sub commit { sub commit {
my $pid; my $pid;
while(@old) {
my @o2; open(my $fh, '|-', qw(git-update-index -z --index-info))
if(@old > 55) { or die "unable to open git-update-index: $!";
@o2 = splice(@old,0,50); print $fh
} else { (map { "0 0000000000000000000000000000000000000000\t$_\0" }
@o2 = @old; @old),
@old = (); (map { '100' . sprintf('%o', $_->[0]) . " $_->[1]\t$_->[2]\0" }
} @new)
system("git-update-index","--force-remove","--",@o2); or die "unable to write to git-update-index: $!";
die "Cannot remove files: $?\n" if $?; close $fh
} or die "unable to write to git-update-index: $!";
while(@new) { $? and die "git-update-index reported error: $?";
my @n2; @old = @new = ();
if(@new > 12) {
@n2 = splice(@new,0,10);
} else {
@n2 = @new;
@new = ();
}
system("git-update-index","--add",
(map { ('--cacheinfo', @$_) } @n2));
die "Cannot add files: $?\n" if $?;
}
$pid = open(C,"-|"); $pid = open(C,"-|");
die "Cannot fork: $!" unless defined $pid; die "Cannot fork: $!" unless defined $pid;