[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: windows filenames

From: Paul Gelderblom \(ptok\)
Subject: Re: windows filenames
Date: Sun, 7 Mar 2004 23:55:53 +0100

address@hidden wrote:

> My question is: How can I set up CVS server to deny adding of a file to a
> folder in repository when there is a file with "the same name from windows
> point of view" ?

I could not find a script doing this; but I had some perl scripts for other
commitinfo tasks lying around.
I now adopted one, to perform this specific task.
I briefly tested it, but it is obviously a version 0.1. Comments
appreciated. YMMV.
Perl script follows below, eable it by putting something like
ALL perl /home/paulg/CVSAdmin/bin/
in your CVSROOT/commitinfo

Is this useful for the contrib folder?

Paul Gelderblom.

#  P. Gelderblom, Mar 2004
#  usage : perl dirname file1 file2 file3 ...
#  checks if a file with the same name but different capitalisation
#  exists in this repository directory. If so, deny the commit.
#  this is useful if the repository has DOS/Windows clients, since they
#  cannot distinguish files based on capitalisation only.
#  ----------------------------------------------
#  This script is to be called from the $CVSROOT/CVSROOT/commitinfo file
#  This means that it will be invoked during a cvs commit, *before*
#  cvs actually does the commit.
#  The CVS server will pass a directory and a set of filenames.
#  When the script finds an illegal commit it will do an "exit 1"
#  ---------------------------------------------
use strict;

my ($dir,@files)address@hidden;
my $cvsroot = $ENV{"CVSROOT"} || die " checkCase : panic: CVSROOT not set!";

my $first=1;
my %existingFiles=();
my $exitvalue=0;
my $debug =0 ;

sub printd($)
  print STDERR @_[0] if $debug;
printd "checkCase: dir= $dir\n";
printd "checkCase: files= @files\n";

# check all the inputfiles
foreach my $file (@files)
  # skip the check for existing files. We can't change the past...
  next if ((-f "$dir/$file,v") || (-f "$dir/Attic/$file,v"));

  # Get filenames in the repos into %existingFiles

  # check if a similar filename exists
  if (exists $existingFiles{lc $file})
    print STDERR "checkCase error: you are trying to commit $file but
".$existingFiles{lc $file}." already exists. \n";
    # additional check: do not allow an "add" of two files with similar
    foreach my $file2 (@files)
      if((lc $file eq lc $file2) && ($file gt $file2) )   # the second check
would normally be "ne" but this way each pair is reported only once.
        print STDERR "checkCase error: you are trying to commit $file and
$file2 at the same time \n";


# print some additional info at the end.
print "    --> Filenames differing by case only are forbidden on this
repository.\n" if ($exitvalue);
exit $exitvalue;

# endo of script... subs follow

# create a hash existingFiles with existing files;
# key= lowcase version of filename,
# value=true filename including path
sub GetExistingFilenames
  # execute this only once
  if ($first)

    # do a dir of the repo dir and the attic
    foreach my $rcsFile (glob ("$dir/*,v") , glob("$dir/Attic/*,v"))
      #remove ,v extension

      # build key: bare filename transformed to lowercase
      my $key=$rcsFile;
      $key=lc $key;

      # remove cvsroot from  the value (make log msg more readible)

    printd "checkCase: existing = " . join("|",%existingFiles). "\n";;

reply via email to

[Prev in Thread] Current Thread [Next in Thread]