script/showdups - show all duplicate files in current repo
This commit is contained in:
parent
038bd0124d
commit
e75811fc5a
38
script/showdups
Executable file
38
script/showdups
Executable file
@ -0,0 +1,38 @@
|
|||||||
|
#!/usr/bin/env perl
|
||||||
|
|
||||||
|
use v5.10;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
open my $fh, "-|", "git ls-tree -r HEAD"
|
||||||
|
or die $!;
|
||||||
|
|
||||||
|
my %fs_sha1_path;
|
||||||
|
|
||||||
|
while ( my $line = <$fh> ) {
|
||||||
|
chomp $line;
|
||||||
|
|
||||||
|
if ( $line =~ m{ \A \d+ \s+ \w+ \s+ (\w+) \s+ (.*) \z }x ) {
|
||||||
|
my $sha1= $1;
|
||||||
|
my $path= $2;
|
||||||
|
if ( -f $path and !-l $path ) {
|
||||||
|
my $fs= -s $path;
|
||||||
|
$fs and push @{ $fs_sha1_path{ $fs }{ $sha1 } }, $path;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for my $fs ( sort { $a <=> $b } keys %fs_sha1_path ) {
|
||||||
|
for my $sha1 (keys %{ $fs_sha1_path{ $fs } } ) {
|
||||||
|
if ( @{ $fs_sha1_path{ $fs }{ $sha1 } } > 1 ) {
|
||||||
|
for my $path ( sort @{ $fs_sha1_path{ $fs }{ $sha1 } } ) {
|
||||||
|
say sprintf "%10d %s %s", $fs, substr($sha1,0,7)."..".substr($sha1,-3), $path;
|
||||||
|
}
|
||||||
|
say '-', ' -' x 39;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
exit;
|
||||||
|
|
||||||
|
__END__
|
||||||
|
|
Loading…
Reference in New Issue
Block a user