contrib / stats / git-common-hashon commit Merge branch 'js/filter-options-should-use-plain-int' (073312b)
   1#!/bin/sh
   2
   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.
   6
   7git 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
  18    }
  19  }
  20  $p = $_;
  21  $pcommon = $common;
  22  END {
  23    $count[$common]++; # last item
  24    print "$_: $count[$_]" for 0..$#count;
  25  }
  26'