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"
8 while case $# in 0) break ;; esac
15 echo >&2 "$1: unknown option"
35 initial
=e83c5163316f89bfbde7d9ab23ca2e25604af290
39 range
="$initial..$this"
43 this
=$
(git rev-parse
--verify "$this^0") &&
44 initial
=$
(git rev-parse
--verify "$initial^0") ||
exit
46 tmp
="/var/tmp/Linus.$$"
47 trap 'rm -f "$tmp".*' 0
49 # We blame each file in the initial revision pretending as if it is a
50 # direct descendant of the given version, and also pretend that the
51 # latter is a root commit. This way, lines in the initial revision
52 # that survived to the other version can be identified (they will be
53 # attributed to the other version).
65 c
=$
(($s * 10000 / $t - $p * 100))
66 printf "%12d %12d %s (%d.%02d%%)\n" $s $t $n $p $c
69 empty_tree
=$
(git hash-object
-t tree
-w --stdin </dev
/null
)
71 git diff-tree
-r --raw $empty_tree $initial -- "$@" |
72 while read mode_old mode_new sha1_old sha1_new op name
74 git blame
$opts --porcelain -S "$graft" "$this..$initial" -- "$name" |
75 sed -ne "s/^\($_x40\) .*/\1/p" |
78 # There are only two commits in the fake history, so
79 # there will be at most two output from the above.
86 if test "$initial" != "$commit1"
92 cnt_total
=$
(( $cnt1 + $cnt2 ))
93 echo "$cnt_surviving $cnt_total $name"
99 printf "%12s %12s %s (survival%%)\n" surviving original path
102 total
=$
(( $total + $t )) surviving
=$
(( $surviving + $s ))
103 test -n "$summary" ||
106 if test -n "$summary"
108 echo $surviving $total
111 show
$surviving $total $label