2 # How much of the very original version from Linus survive?
4 _x40
='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
5 _x40
="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
7 initial
=$
(git rev-parse
--verify e83c5163316f89bfbde7d9ab23ca2e25604af290
) &&
8 this
=$
(git rev-parse
--verify ${1-HEAD}^
0) ||
exit
10 tmp
="/var/tmp/Linus.$$"
11 trap 'rm -f "$tmp".*' 0
13 # We blame each file in the initial revision pretending as if it is a
14 # direct descendant of the given version, and also pretend that the
15 # latter is a root commit. This way, lines in the initial revision
16 # that survived to the other version can be identified (they will be
17 # attributed to the other version).
29 c
=$
(($s * 10000 / $t - $p * 100))
30 printf "%12d %12d %s (%d.%02d%%)\n" $s $t $n $p $c
33 git ls-tree
-r "$initial" |
34 while read mode
type sha1 name
36 git blame
$opts --porcelain -S "$graft" "$initial" -- "$name" |
37 sed -ne "s/^\($_x40\) .*/\1/p" |
40 # There are only two commits in the fake history, so
41 # there will be at most two output from the above.
48 if test "$initial" != "$commit1"
54 cnt_total
=$
(( $cnt1 + $cnt2 ))
55 echo "$cnt_surviving $cnt_total $name"
60 printf "%12s %12s %s (survival%%)\n" surviving original path
63 total
=$
(( $total + $t )) surviving
=$
(( $surviving + $s ))
64 # printf "%12d %12d %s\n" $s $t $n
67 # printf "%12d %12d %s\n" $surviving $total Total
68 show
$surviving $total Total