git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v4] cvsserver: remove unused escapeRefName function

From
OGOndřej Pohořelský via GitGitGadget <gitgitgadget@gmail.com>
Date
May 26, 2025, 13:48 UTC
Message-ID
<pull.1925.v4.git.1748267305871.gitgitgadget@gmail.com>
In-Reply-To
<pull.1925.v3.git.1747913206622.gitgitgadget@gmail.com>
From: =?UTF-8?q?Ond=C5=99ej=20Poho=C5=99elsk=C3=BD?= <opohorel@redhat.com>
Function 'escapeRefName' introduced in 51a7e6dbc9 has never been used.

Despite being dead code, changes in Perl 5.41.4 exposed precedence warning withing its logic, which then caused test failures in t9402 by logging the warnings to stderr while parsing the code. The affected tests are t9402.30, t9402.31, t9402.32 and t9402.34.

Remove this unused function to simplify the codebase and stop the warnings and test failures. Its corresponding unescapeRefName function, which remains in use, has had its comments updated.

Reported-by: Jitka Plesnikova <jplesnik@redhat.com>
Signed-off-by: Ondřej Pohořelský <opohorel@redhat.com>
---
    cvsserver: avoid precedence problem between ! and %s
    
    cc: "Kristoffer Haugsbakk" kristofferhaugsbakk@fastmail.com cc: "brian
    m. carlson" sandals@crustytoothpaste.net cc: Jeff King peff@peff.net cc:
    Todd Zullinger tmz@pobox.com cc: Matthew Ogilvie mmogilvi+git@zoho.com
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1925%2Fopohorel%2Fcvsserver_parentheses-v4
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1925/opohorel/cvsserver_parentheses-v4
Pull-Request: https://github.com/gitgitgadget/git/pull/1925
Range-diff vs v3:
 1:  b7563182492 ! 1:  ce853594ceb cvsserver: avoid precedence problem between ! and %s
     @@ Metadata
      Author: Ondřej Pohořelský <opohorel@redhat.com>
      
       ## Commit message ##
     -    cvsserver: avoid precedence problem between ! and %s
     +    cvsserver: remove unused escapeRefName function
      
     -    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.
     +    Function 'escapeRefName' introduced in 51a7e6dbc9 has never been used.
      
     -    Use the 'does not match' operator '!~' directly to express the
     -    negated pattern match, resolving the precedence issue.
     +    Despite being dead code, changes in Perl 5.41.4 exposed precedence
     +    warning withing its logic, which then caused test failures in t9402 by
     +    logging the warnings to stderr while parsing the code. The affected
     +    tests are t9402.30, t9402.31, t9402.32 and t9402.34.
      
     -    [0] https://metacpan.org/release/ETHER/perl-5.41.12/view/pod/perl5414delta.pod#New-Warnings
     +    Remove this unused function to simplify the codebase and stop the
     +    warnings and test failures. Its corresponding unescapeRefName function,
     +    which remains in use, has had its comments updated.
      
          Reported-by: Jitka Plesnikova <jplesnik@redhat.com>
     -    Suggested-by: Jitka Plesnikova <jplesnik@redhat.com>
          Signed-off-by: Ondřej Pohořelský <opohorel@redhat.com>
      
       ## git-cvsserver.perl ##
     +@@ git-cvsserver.perl: sub gethistorydense
     +     return $result;
     + }
     + 
     +-=head2 escapeRefName
     ++=head2 unescapeRefName
     + 
     +-Apply an escape mechanism to compensate for characters that
     ++Undo an escape mechanism to compensate for characters that
     + git ref names can have that CVS tags can not.
     + 
     + =cut
     +-sub escapeRefName
     ++sub unescapeRefName
     + {
     +     my($self,$refName)=@_;
     + 
      @@ git-cvsserver.perl: 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;
     +-    {
     +-        $refName=~s/_-/_-u--/g;
     +-        $refName=~s/\./_-p-/g;
     +-        $refName=~s%/%_-s-%g;
     +-        $refName=~s/[^-_a-zA-Z0-9]/sprintf("_-%02x-",$1)/eg;
     +-    }
     +-}
     +-
     +-=head2 unescapeRefName
     +-
     +-Undo an escape mechanism to compensate for characters that
     +-git ref names can have that CVS tags can not.
     +-
     +-=cut
     +-sub unescapeRefName
     +-{
     +-    my($self,$refName)=@_;
     +-
     +-    # see escapeRefName() for description of escape mechanism.
     +-
     +     $refName=~s/_-([spu]|[0-9a-f][0-9a-f])-/unescapeRefNameChar($1)/eg;
     + 
     +     # allowed tag names
 git-cvsserver.perl | 27 +++------------------------
 1 file changed, 3 insertions(+), 24 deletions(-)
diff --git a/git-cvsserver.perl b/git-cvsserver.perl
index a4e1bad33ca..d8d5422cbca 100755
--- a/git-cvsserver.perl
+++ b/git-cvsserver.perl
@@ -4986,13 +4986,13 @@ sub gethistorydense
     return $result;
 }
 
-=head2 escapeRefName
+=head2 unescapeRefName
 
-Apply an escape mechanism to compensate for characters that
+Undo an escape mechanism to compensate for characters that
 git ref names can have that CVS tags can not.
 
 =cut
-sub escapeRefName
+sub unescapeRefName
 {
     my($self,$refName)=@_;
 
@@ -5009,27 +5009,6 @@ 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]*)*$/)
-    {
-        $refName=~s/_-/_-u--/g;
-        $refName=~s/\./_-p-/g;
-        $refName=~s%/%_-s-%g;
-        $refName=~s/[^-_a-zA-Z0-9]/sprintf("_-%02x-",$1)/eg;
-    }
-}
-
-=head2 unescapeRefName
-
-Undo an escape mechanism to compensate for characters that
-git ref names can have that CVS tags can not.
-
-=cut
-sub unescapeRefName
-{
-    my($self,$refName)=@_;
-
-    # see escapeRefName() for description of escape mechanism.
-
     $refName=~s/_-([spu]|[0-9a-f][0-9a-f])-/unescapeRefNameChar($1)/eg;
 
     # allowed tag names

base-commit: cb96e1697ad6e54d11fc920c95f82977f8e438f8
-- 
gitgitgadget
Previous: Ondřej Pohořelský via GitGitGadgetNext: Junio C Hamano
Message 17 of 21 in “cvsserver: avoid precedence problem between ! and %s”
  1. cvsserver: avoid precedence problem between ! and %sOndřej Pohořelský via GitGitGadget, May 21, 2025
  2. Kristoffer HaugsbakkMay 21, 2025
  3. cvsserver: avoid precedence problem between ! and %sOndřej Pohořelský via GitGitGadget, May 21, 2025
  4. Junio C HamanoMay 21, 2025
  5. Junio C HamanoMay 21, 2025
  6. Junio C HamanoMay 21, 2025
  7. Ondrej PohorelskyMay 22, 2025
  8. Junio C HamanoMay 22, 2025
  9. Jeff KingMay 22, 2025
  10. Todd ZullingerMay 22, 2025
  11. Junio C HamanoMay 22, 2025
  12. Matthew OgilvieMay 23, 2025
  13. Junio C HamanoMay 23, 2025
  14. Ondrej PohorelskyMay 26, 2025
  15. Junio C HamanoMay 27, 2025
  16. cvsserver: avoid precedence problem between ! and %sOndřej Pohořelský via GitGitGadget, May 22, 2025
  17. cvsserver: remove unused escapeRefName functionOndřej Pohořelský via GitGitGadget, May 26, 2025
  18. Junio C HamanoMay 27, 2025
  19. Junio C HamanoMay 21, 2025
  20. brian m. carlsonMay 21, 2025
  21. Ondrej PohorelskyMay 22, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.