Skip to content

Commit 9462953

Browse files
anderskgitster
authored andcommitted
cvsserver: Determinize output to combat Perl 5.18 hash randomization
Perl 5.18 randomizes the seed used by its hash function, so iterating through hashes results in different orders from run to run: http://perldoc.perl.org/perl5180delta.html#Hash-overhaul This usually broke t9400 (gitcvs.dbname, gitcvs.ext.dbname, when running cmp on two .sqlite files) and t9402 (check [cvswork3] diff, when running test_cmp on two diffs). To fix this, hide the internal order of hashes with sort when sending output or running database queries. (An alternative workaround is PERL_HASH_SEED=0, but this seems nicer.) Signed-off-by: Anders Kaseorg <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 1b48d56 commit 9462953

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

git-cvsserver.perl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -430,10 +430,10 @@ sub req_validrequests
430430

431431
$log->debug("req_validrequests");
432432

433-
$log->debug("SEND : Valid-requests " . join(" ",keys %$methods));
433+
$log->debug("SEND : Valid-requests " . join(" ",sort keys %$methods));
434434
$log->debug("SEND : ok");
435435

436-
print "Valid-requests " . join(" ",keys %$methods) . "\n";
436+
print "Valid-requests " . join(" ",sort keys %$methods) . "\n";
437437
print "ok\n";
438438
}
439439

@@ -2124,7 +2124,7 @@ sub req_diff
21242124
print "M retrieving revision $meta2->{revision}\n"
21252125
}
21262126
print "M diff ";
2127-
foreach my $opt ( keys %{$state->{opt}} )
2127+
foreach my $opt ( sort keys %{$state->{opt}} )
21282128
{
21292129
if ( ref $state->{opt}{$opt} eq "ARRAY" )
21302130
{
@@ -4050,7 +4050,7 @@ sub update
40504050
close FILELIST;
40514051

40524052
# Detect deleted files
4053-
foreach my $file ( keys %$head )
4053+
foreach my $file ( sort keys %$head )
40544054
{
40554055
unless ( exists $seen_files->{$file} or $head->{$file}{filehash} eq "deleted" )
40564056
{
@@ -4078,7 +4078,7 @@ sub update
40784078
}
40794079

40804080
$self->delete_head();
4081-
foreach my $file ( keys %$head )
4081+
foreach my $file ( sort keys %$head )
40824082
{
40834083
$self->insert_head(
40844084
$file,

0 commit comments

Comments
 (0)