mirror of
https://github.com/git/git.git
synced 2024-05-19 11:46:07 +02:00
git-cvsserver: detect/diagnose write failure, etc.
There were many operations that did not notice and report errors to the CVS client, which would have resulted in corrupt working tree. Signed-off-by: Jim Meyering <jim@meyering.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
4cb08df553
commit
a5e407988b
|
@ -623,8 +623,12 @@ sub req_Modified
|
||||||
my ( $cmd, $data ) = @_;
|
my ( $cmd, $data ) = @_;
|
||||||
|
|
||||||
my $mode = <STDIN>;
|
my $mode = <STDIN>;
|
||||||
|
defined $mode
|
||||||
|
or (print "E end of file reading mode for $data\n"), return;
|
||||||
chomp $mode;
|
chomp $mode;
|
||||||
my $size = <STDIN>;
|
my $size = <STDIN>;
|
||||||
|
defined $size
|
||||||
|
or (print "E end of file reading size of $data\n"), return;
|
||||||
chomp $size;
|
chomp $size;
|
||||||
|
|
||||||
# Grab config information
|
# Grab config information
|
||||||
|
@ -644,7 +648,8 @@ sub req_Modified
|
||||||
$bytesleft -= $blocksize;
|
$bytesleft -= $blocksize;
|
||||||
}
|
}
|
||||||
|
|
||||||
close $fh;
|
close $fh
|
||||||
|
or (print "E failed to write temporary, $filename: $!\n"), return;
|
||||||
|
|
||||||
# Ensure we have something sensible for the file mode
|
# Ensure we have something sensible for the file mode
|
||||||
if ( $mode =~ /u=(\w+)/ )
|
if ( $mode =~ /u=(\w+)/ )
|
||||||
|
@ -901,8 +906,13 @@ sub req_update
|
||||||
# projects (heads in this case) to checkout.
|
# projects (heads in this case) to checkout.
|
||||||
#
|
#
|
||||||
if ($state->{module} eq '') {
|
if ($state->{module} eq '') {
|
||||||
|
my $heads_dir = $state->{CVSROOT} . '/refs/heads';
|
||||||
|
if (!opendir HEADS, $heads_dir) {
|
||||||
|
print "E [server aborted]: Failed to open directory, "
|
||||||
|
. "$heads_dir: $!\nerror\n";
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
print "E cvs update: Updating .\n";
|
print "E cvs update: Updating .\n";
|
||||||
opendir HEADS, $state->{CVSROOT} . '/refs/heads';
|
|
||||||
while (my $head = readdir(HEADS)) {
|
while (my $head = readdir(HEADS)) {
|
||||||
if (-f $state->{CVSROOT} . '/refs/heads/' . $head) {
|
if (-f $state->{CVSROOT} . '/refs/heads/' . $head) {
|
||||||
print "E cvs update: New directory `$head'\n";
|
print "E cvs update: New directory `$head'\n";
|
||||||
|
@ -1737,14 +1747,16 @@ sub req_annotate
|
||||||
system("git-read-tree", $lastseenin);
|
system("git-read-tree", $lastseenin);
|
||||||
unless ($? == 0)
|
unless ($? == 0)
|
||||||
{
|
{
|
||||||
die "Error running git-read-tree $lastseenin $file_index $!";
|
print "E error running git-read-tree $lastseenin $file_index $!\n";
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
$log->info("Created index '$file_index' with commit $lastseenin - exit status $?");
|
$log->info("Created index '$file_index' with commit $lastseenin - exit status $?");
|
||||||
|
|
||||||
# do a checkout of the file
|
# do a checkout of the file
|
||||||
system('git-checkout-index', '-f', '-u', $filename);
|
system('git-checkout-index', '-f', '-u', $filename);
|
||||||
unless ($? == 0) {
|
unless ($? == 0) {
|
||||||
die "Error running git-checkout-index -f -u $filename : $!";
|
print "E error running git-checkout-index -f -u $filename : $!\n";
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$log->info("Annotate $filename");
|
$log->info("Annotate $filename");
|
||||||
|
@ -1754,7 +1766,11 @@ sub req_annotate
|
||||||
# git-jsannotate telling us about commits we are hiding
|
# git-jsannotate telling us about commits we are hiding
|
||||||
# from the client.
|
# from the client.
|
||||||
|
|
||||||
open(ANNOTATEHINTS, ">$tmpdir/.annotate_hints") or die "Error opening > $tmpdir/.annotate_hints $!";
|
my $a_hints = "$tmpdir/.annotate_hints";
|
||||||
|
if (!open(ANNOTATEHINTS, '>', $a_hints)) {
|
||||||
|
print "E failed to open '$a_hints' for writing: $!\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
for (my $i=0; $i < @$revisions; $i++)
|
for (my $i=0; $i < @$revisions; $i++)
|
||||||
{
|
{
|
||||||
print ANNOTATEHINTS $revisions->[$i][2];
|
print ANNOTATEHINTS $revisions->[$i][2];
|
||||||
|
@ -1765,11 +1781,14 @@ sub req_annotate
|
||||||
}
|
}
|
||||||
|
|
||||||
print ANNOTATEHINTS "\n";
|
print ANNOTATEHINTS "\n";
|
||||||
close ANNOTATEHINTS;
|
close ANNOTATEHINTS
|
||||||
|
or (print "E failed to write $a_hints: $!\n"), return;
|
||||||
|
|
||||||
my $annotatecmd = 'git-annotate';
|
my @cmd = (qw(git-annotate -l -S), $a_hints, $filename);
|
||||||
open(ANNOTATE, "-|", $annotatecmd, '-l', '-S', "$tmpdir/.annotate_hints", $filename)
|
if (!open(ANNOTATE, "-|", @cmd)) {
|
||||||
or die "Error invoking $annotatecmd -l -S $tmpdir/.annotate_hints $filename : $!";
|
print "E error invoking ". join(' ',@cmd) .": $!\n";
|
||||||
|
return;
|
||||||
|
}
|
||||||
my $metadata = {};
|
my $metadata = {};
|
||||||
print "E Annotations for $filename\n";
|
print "E Annotations for $filename\n";
|
||||||
print "E ***************\n";
|
print "E ***************\n";
|
||||||
|
@ -1996,12 +2015,12 @@ sub transmitfile
|
||||||
{
|
{
|
||||||
open NEWFILE, ">", $targetfile or die("Couldn't open '$targetfile' for writing : $!");
|
open NEWFILE, ">", $targetfile or die("Couldn't open '$targetfile' for writing : $!");
|
||||||
print NEWFILE $_ while ( <$fh> );
|
print NEWFILE $_ while ( <$fh> );
|
||||||
close NEWFILE;
|
close NEWFILE or die("Failed to write '$targetfile': $!");
|
||||||
} else {
|
} else {
|
||||||
print "$size\n";
|
print "$size\n";
|
||||||
print while ( <$fh> );
|
print while ( <$fh> );
|
||||||
}
|
}
|
||||||
close $fh or die ("Couldn't close filehandle for transmitfile()");
|
close $fh or die ("Couldn't close filehandle for transmitfile(): $!");
|
||||||
} else {
|
} else {
|
||||||
die("Couldn't execute git-cat-file");
|
die("Couldn't execute git-cat-file");
|
||||||
}
|
}
|
||||||
|
@ -2501,17 +2520,14 @@ sub update
|
||||||
if ($parent eq $lastpicked) {
|
if ($parent eq $lastpicked) {
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
open my $p, 'git-merge-base '. $lastpicked . ' '
|
my $base = safe_pipe_capture('git-merge-base',
|
||||||
. $parent . '|';
|
$lastpicked, $parent);
|
||||||
my @output = (<$p>);
|
|
||||||
close $p;
|
|
||||||
my $base = join('', @output);
|
|
||||||
chomp $base;
|
chomp $base;
|
||||||
if ($base) {
|
if ($base) {
|
||||||
my @merged;
|
my @merged;
|
||||||
# print "want to log between $base $parent \n";
|
# print "want to log between $base $parent \n";
|
||||||
open(GITLOG, '-|', 'git-log', "$base..$parent")
|
open(GITLOG, '-|', 'git-log', "$base..$parent")
|
||||||
or die "Cannot call git-log: $!";
|
or die "Cannot call git-log: $!";
|
||||||
my $mergedhash;
|
my $mergedhash;
|
||||||
while (<GITLOG>) {
|
while (<GITLOG>) {
|
||||||
chomp;
|
chomp;
|
||||||
|
|
Loading…
Reference in New Issue