summaryrefslogtreecommitdiff
path: root/BitKeeper/triggers/pre-commit.check-case.pl
blob: 4f68f8619e5426db0845bb7caa2b758c637cb557 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/perl
my $status = 0;

my $pending = $ENV{'BK_PENDING'};
exit 0 unless -f $pending;

open FI, "<", $pending || exit 0;
while(<FI>) {
	my ($file, $stuff) = split /\|/, $_, 2;
	next unless -f $file;
	$file =~ s/^(.*)\/([^\/]*)$/$2/;
	my $path = $1;
	opendir DIR, $path;
	my @files = sort map { lc } readdir DIR;
	closedir DIR;
	my %count = ();
	$count{$_}++ for @files;
	@files = grep { $count{$_} > 1 } keys %count;
	if(@files > 0) {
		print "$path/$file: duplicate file names: " . (join " ", @files) . "\n";
		$status = 1;
	}
}
close FI;

exit $status;