bash completion: add basic support for git-reflog
[git/raj.git] / contrib / stats / git-common-hash
blobe27fd088be1bd3ecc3da116d5f32ce10d89897ac
1 #!/bin/sh
3 # This script displays the distribution of longest common hash prefixes.
4 # This can be used to determine the minimum prefix length to use
5 # for object names to be unique.
7 git rev-list --objects --all | sort | perl -lne '
8 substr($_, 40) = "";
9 # uncomment next line for a distribution of bits instead of hex chars
10 # $_ = unpack("B*",pack("H*",$_));
11 if (defined $p) {
12 ($p ^ $_) =~ /^(\0*)/;
13 $common = length $1;
14 if (defined $pcommon) {
15 $count[$pcommon > $common ? $pcommon : $common]++;
16 } else {
17 $count[$common]++; # first item
20 $p = $_;
21 $pcommon = $common;
22 END {
23 $count[$common]++; # last item
24 print "$_: $count[$_]" for 0..$#count;