[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

[PATCH] Check for case collisions within transactions

From: Michael Brouwer <michael_at_tlaloc.net>
Date: 2005-07-14 20:19:11 CEST

As a long time dev list lurker here is my first modest attempt at a
patch ;-)

Michael

----
[[[
Fix a bug in the pre-commit hook script that is prevents case  
collisions, which would allow a transaction to add 2 files which  
collide within a single transaction.
* contrib/hook-scripts/check-case-insensitive.pl
   (%newtree): New hash which tracks the case folded adds within the  
transaction.
   ($lcnewfile): New scalar to cache case folded version of the  
current file.
   (global scope): Add a check to see if the case folded current file  
is already in the transaction.
]]]
Index: contrib/hook-scripts/check-case-insensitive.pl
===================================================================
--- contrib/hook-scripts/check-case-insensitive.pl      (revision 15336)
+++ contrib/hook-scripts/check-case-insensitive.pl      (working copy)
@@ -237,14 +237,20 @@
close SVNLOOK;
my $failmsg;
+my %newtree;
foreach my $newfile (@added) {
    print STDERR "Checking \$tree{lc($newfile)}\n" if ($debug > 1);
    # Without the following line it gets the lc() wrong.
    my $junk = "x$newfile";
-  if (exists($tree{lc($newfile)})) {
+  my $lcnewfile = lc($newfile);
+  if (exists($tree{$lcnewfile})) {
      $failmsg .= "\n  $newfile already exists as " . $tree{lc 
($newfile)};
    }
+  elsif (exists($newtree{$lcnewfile})) {
+    $failmsg .= "\n  $newfile also added as " . $newtree{lc($newfile)};
+  }
+  $newtree{$lcnewfile} = $newfile;
}
if (defined($failmsg)) {
    print STDERR "\nFile name case conflict found:\n" . $failmsg . "\n";
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Thu Jul 14 20:19:57 2005

This is an archived mail posted to the Subversion Dev mailing list.