~ubuntu-branches/ubuntu/intrepid/git-core/intrepid-updates

« back to all changes in this revision

Viewing changes to contrib/stats/git-common-hash

  • Committer: Package Import Robot
  • Author(s): Gerrit Pape
  • Date: 2007-10-04 08:27:01 UTC
  • mfrom: (1.1.23)
  • Revision ID: package-import@ubuntu.com-20071004082701-rsd058ontoqz4i30
Tags: 1:1.5.3.4-1
new upstream point release (closes: #445188).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
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
 
18
    }
 
19
  }
 
20
  $p = $_;
 
21
  $pcommon = $common;
 
22
  END {
 
23
    $count[$common]++; # last item
 
24
    print "$_: $count[$_]" for 0..$#count;
 
25
  }
 
26
'