@@ -365,7 +365,7 @@ sub req_Root
365
365
}
366
366
foreach my $line ( @gitvars )
367
367
{
368
- next unless ( $line =~ / ^(gitcvs)\. (?:(ext|pserver)\. )?([\w -]+)=(.*)$ / );
368
+ next unless ( $line =~ / ^(gitcvs|extensions )\. (?:(ext|pserver)\. )?([\w -]+)=(.*)$ / );
369
369
unless ($2 ) {
370
370
$cfg -> {$1 }{$3 } = $4 ;
371
371
} else {
@@ -392,6 +392,9 @@ sub req_Root
392
392
$log -> nofile();
393
393
}
394
394
395
+ $state -> {rawsz } = ($cfg -> {' extensions' }{' objectformat' } || ' sha1' ) eq ' sha256' ? 32 : 20;
396
+ $state -> {hexsz } = $state -> {rawsz } * 2;
397
+
395
398
return 1;
396
399
}
397
400
@@ -1581,7 +1584,7 @@ sub req_ci
1581
1584
1582
1585
$parenthash = safe_pipe_capture(' git' , ' show-ref' , ' -s' , $branchRef );
1583
1586
chomp $parenthash ;
1584
- if ($parenthash !~ / ^[0-9a-f]{40 }$ / )
1587
+ if ($parenthash !~ / ^[0-9a-f]{$state ->{hexsz} }$ / )
1585
1588
{
1586
1589
if ( defined ($stickyInfo ) && defined ($stickyInfo -> {tag }) )
1587
1590
{
@@ -1708,7 +1711,7 @@ sub req_ci
1708
1711
chomp ($commithash );
1709
1712
$log -> info(" Commit hash : $commithash " );
1710
1713
1711
- unless ( $commithash =~ / [a-zA-Z0-9]{40 }/ )
1714
+ unless ( $commithash =~ / [a-zA-Z0-9]{$state ->{hexsz} }/ )
1712
1715
{
1713
1716
$log -> warn (" Commit failed (Invalid commit hash)" );
1714
1717
print " error 1 Commit failed (unknown reason)\n " ;
@@ -2375,7 +2378,7 @@ sub req_annotate
2375
2378
print " E ***************\n " ;
2376
2379
while ( <ANNOTATE> )
2377
2380
{
2378
- if (m / ^([a-zA-Z0-9]{40 })\t\( [^\) ] *\) (.*)$ / i )
2381
+ if (m / ^([a-zA-Z0-9]{$state ->{hexsz} })\t\( [^\) ] *\) (.*)$ / i )
2379
2382
{
2380
2383
my $commithash = $1 ;
2381
2384
my $data = $2 ;
@@ -2852,7 +2855,7 @@ sub transmitfile
2852
2855
return ;
2853
2856
}
2854
2857
2855
- die " Need filehash" unless ( defined ( $filehash ) and $filehash =~ / ^[a-zA-Z0-9]{40 }$ / );
2858
+ die " Need filehash" unless ( defined ( $filehash ) and $filehash =~ / ^[a-zA-Z0-9]{$state ->{hexsz} }$ / );
2856
2859
2857
2860
my $type = safe_pipe_capture(' git' , ' cat-file' , ' -t' , $filehash );
2858
2861
chomp $type ;
@@ -3042,7 +3045,7 @@ sub ensureWorkTree
3042
3045
3043
3046
my $ver = safe_pipe_capture(' git' , ' show-ref' , ' -s' , " refs/heads/$state ->{module}" );
3044
3047
chomp $ver ;
3045
- if ($ver !~ / ^[0-9a-f]{40 }$ / )
3048
+ if ($ver !~ / ^[0-9a-f]{$state ->{hexsz} }$ / )
3046
3049
{
3047
3050
$log -> warn (" Error from git show-ref -s refs/head$state ->{module}" );
3048
3051
print " error 1 cannot find the current HEAD of module" ;
@@ -3281,7 +3284,7 @@ sub open_blob_or_die
3281
3284
}
3282
3285
elsif ( $srcType eq " sha1" )
3283
3286
{
3284
- unless ( defined ( $name ) and $name =~ / ^[a-zA-Z0-9]{40 }$ / )
3287
+ unless ( defined ( $name ) and $name =~ / ^[a-zA-Z0-9]{$state ->{hexsz} }$ / )
3285
3288
{
3286
3289
$log -> warn (" Need filehash" );
3287
3290
die " Need filehash\n " ;
@@ -3817,7 +3820,7 @@ sub update
3817
3820
chomp $commitsha1 ;
3818
3821
3819
3822
my $commitinfo = ::safe_pipe_capture(' git' , ' cat-file' , ' commit' , $self -> {module });
3820
- unless ( $commitinfo =~ / tree\s +[a-zA-Z0-9]{40 }/ )
3823
+ unless ( $commitinfo =~ / tree\s +[a-zA-Z0-9]{$state ->{hexsz} }/ )
3821
3824
{
3822
3825
die (" Invalid module '$self ->{module}'" );
3823
3826
}
@@ -3957,7 +3960,7 @@ sub update
3957
3960
while ( <FILELIST> )
3958
3961
{
3959
3962
chomp ;
3960
- unless ( / ^:\d {6}\s +([0-7]{6})\s +[a-f0-9]{40} \s +([a-f0-9]{40 })\s +(\w )$ /o )
3963
+ unless ( / ^:\d {6}\s +([0-7]{6})\s +[a-f0-9]{$state ->{hexsz}} \s +([a-f0-9]{$state ->{hexsz} })\s +(\w )$ /o )
3961
3964
{
3962
3965
die (" Couldn't process git-diff-tree line : $_ " );
3963
3966
}
@@ -4625,11 +4628,11 @@ sub getmeta
4625
4628
$db_query -> execute($filename , $intRev );
4626
4629
$meta = $db_query -> fetchrow_hashref;
4627
4630
}
4628
- elsif ( $revision =~ / ^2\. 1\. 1\. 2000(\. [1-3][0-9][0-9]){20 }$ / )
4631
+ elsif ( $revision =~ / ^2\. 1\. 1\. 2000(\. [1-3][0-9][0-9]){$state ->{rawsz} }$ / )
4629
4632
{
4630
4633
my ($commitHash )=($revision =~/ ^2\. 1\. 1\. 2000(.*)$ / );
4631
4634
$commitHash =~s /\. ([0-9]+)/ sprintf("%02x",$1 -100)/ eg ;
4632
- if ($commitHash =~/ ^[0-9a-f]{40 }$ / )
4635
+ if ($commitHash =~/ ^[0-9a-f]{$state ->{hexsz} }$ / )
4633
4636
{
4634
4637
return $self -> getMetaFromCommithash($filename ,$commitHash );
4635
4638
}
@@ -4639,7 +4642,7 @@ sub getmeta
4639
4642
$log -> warning(" failed get $revision with commithash=$commitHash " );
4640
4643
undef $revision ;
4641
4644
}
4642
- elsif ( $revision =~ / ^[0-9a-f]{40 }$ / )
4645
+ elsif ( $revision =~ / ^[0-9a-f]{$state ->{hexsz} }$ / )
4643
4646
{
4644
4647
# Try DB first. This is mostly only useful for req_annotate(),
4645
4648
# which only calls this for stuff that should already be in
@@ -4658,7 +4661,7 @@ sub getmeta
4658
4661
if (! $meta )
4659
4662
{
4660
4663
my ($revCommit )=$self -> lookupCommitRef($revision );
4661
- if ($revCommit =~/ ^[0-9a-f]{40 }$ / )
4664
+ if ($revCommit =~/ ^[0-9a-f]{$state ->{hexsz} }$ / )
4662
4665
{
4663
4666
return $self -> getMetaFromCommithash($filename ,$revCommit );
4664
4667
}
@@ -4672,7 +4675,7 @@ sub getmeta
4672
4675
else
4673
4676
{
4674
4677
my ($revCommit )=$self -> lookupCommitRef($revision );
4675
- if ($revCommit =~/ ^[0-9a-f]{40 }$ / )
4678
+ if ($revCommit =~/ ^[0-9a-f]{$state ->{hexsz} }$ / )
4676
4679
{
4677
4680
return $self -> getMetaFromCommithash($filename ,$revCommit );
4678
4681
}
@@ -4767,7 +4770,7 @@ sub getMetaFromCommithash
4767
4770
4768
4771
my ($fileHash ) = ::safe_pipe_capture(" git" ," rev-parse" ," $revCommit :$filename " );
4769
4772
chomp $fileHash ;
4770
- if (!($fileHash =~/ ^[0-9a-f]{40 }$ / ))
4773
+ if (!($fileHash =~/ ^[0-9a-f]{$state ->{hexsz} }$ / ))
4771
4774
{
4772
4775
die " Invalid fileHash '$fileHash ' looking up"
4773
4776
." '$revCommit :$filename '\n " ;
@@ -4863,7 +4866,7 @@ sub lookupCommitRef
4863
4866
$commitHash = ::safe_pipe_capture(" git" ," rev-parse" ," --verify" ," --quiet" ,
4864
4867
$self -> unescapeRefName($ref ));
4865
4868
$commitHash =~s /\s *$// ;
4866
- if (!($commitHash =~/ ^[0-9a-f]{40 }$ / ))
4869
+ if (!($commitHash =~/ ^[0-9a-f]{$state ->{hexsz} }$ / ))
4867
4870
{
4868
4871
$commitHash =undef ;
4869
4872
}
@@ -4909,7 +4912,7 @@ sub commitmessage
4909
4912
my $commithash = shift ;
4910
4913
my $tablename = $self -> tablename(" commitmsgs" );
4911
4914
4912
- die (" Need commithash" ) unless ( defined ($commithash ) and $commithash =~ / ^[a-zA-Z0-9]{40 }$ / );
4915
+ die (" Need commithash" ) unless ( defined ($commithash ) and $commithash =~ / ^[a-zA-Z0-9]{$state ->{hexsz} }$ / );
4913
4916
4914
4917
my $db_query ;
4915
4918
$db_query = $self -> {dbh }-> prepare_cached(" SELECT value FROM $tablename WHERE key=?" ,{},1);
0 commit comments