Subject: [PATCH v3] cvsserver: avoid precedence problem between ! and %s

From: "Ondřej Pohořelský via GitGitGadget" <[email-masked]>
Date: Thu, 22 May 2025 11:26:46 +0000

From: =?UTF-8?q?Ond=C5=99ej=20Poho=C5=99elsk=C3=BD?= <[email-masked]>

With perl-5.41.4 and newer, test t9402-git-cvsserver-refs.sh
(specifically t9402.30, t9402.31, t9402.32, t9402.34) fails, because
of the new warnings[0] populating cvs.log.

Use the 'does not match' operator '!~' directly to express the
negated pattern match, resolving the precedence issue.

[0] https://metacpan.org/release/ETHER/perl-5.41.12/view/pod/perl5414delta.pod#New-Warnings

Reported-by: Jitka Plesnikova <[email-masked]>
Suggested-by: Jitka Plesnikova <[email-masked]>
Signed-off-by: Ondřej Pohořelský <[email-masked]>
---
    cvsserver: avoid precedence problem between ! and %s
    
    cc: "Kristoffer Haugsbakk" [email-masked] cc: "brian
    m. carlson" [email-masked]

Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1925%2Fopohorel%2Fcvsserver_parentheses-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1925/opohorel/cvsserver_parentheses-v3
Pull-Request: https://github.com/gitgitgadget/git/pull/1925

Range-diff vs v2:

 1:  a15f924657c ! 1:  b7563182492 cvsserver: avoid precedence problem between ! and %s
     @@ Metadata
       ## Commit message ##
          cvsserver: avoid precedence problem between ! and %s
      
     -    With perl-5.41.4 and newer, git-cvsserver fails to build because of
     -    possible precedence problem[0]
     +    With perl-5.41.4 and newer, test t9402-git-cvsserver-refs.sh
     +    (specifically t9402.30, t9402.31, t9402.32, t9402.34) fails, because
     +    of the new warnings[0] populating cvs.log.
      
     -    Added parentheses avoid this issue.
     +    Use the 'does not match' operator '!~' directly to express the
     +    negated pattern match, resolving the precedence issue.
      
          [0] https://metacpan.org/release/ETHER/perl-5.41.12/view/pod/perl5414delta.pod#New-Warnings
      
     @@ git-cvsserver.perl: sub escapeRefName
           #     desired ASCII character byte. (for anything else)
       
      -    if(! $refName=~/^[1-9][0-9]*(\.[1-9][0-9]*)*$/)
     -+    if(! ($refName=~/^[1-9][0-9]*(\.[1-9][0-9]*)*$/))
     ++    if ($refName !~ /^[1-9][0-9]*(\.[1-9][0-9]*)*$/)
           {
               $refName=~s/_-/_-u--/g;
               $refName=~s/\./_-p-/g;

 git-cvsserver.perl | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/git-cvsserver.perl b/git-cvsserver.perl
index a4e1bad33ca..7ccd720019b 100755
--- a/git-cvsserver.perl
+++ b/git-cvsserver.perl
@@ -5009,7 +5009,7 @@ sub escapeRefName
     #   = "_-xx-" Where "xx" is the hexadecimal representation of the
     #     desired ASCII character byte. (for anything else)
 
-    if(! $refName=~/^[1-9][0-9]*(\.[1-9][0-9]*)*$/)
+    if ($refName !~ /^[1-9][0-9]*(\.[1-9][0-9]*)*$/)
     {
         $refName=~s/_-/_-u--/g;
         $refName=~s/\./_-p-/g;

base-commit: cb96e1697ad6e54d11fc920c95f82977f8e438f8
-- 
gitgitgadget