Blob


1 # diffstat
3 Show diff statistics.
5 #!/usr/bin/awk -f
7 maybe not 100% correct, but it's one case where being simple yet
8 slightly wrong is way easier than correct. It's not a catastrophe to
9 count some extra lines, while parsing the diff (possibly enclosed in a
10 mail) is hard.
12 /^\+/ { a++ }
13 /^\-/ { m++ }
15 Don't be a sink! Continue the pipeline so we can further save or apply
16 the diff.
18 // { print $0 }
20 At the end, print the stats to standard error to avoid mangling the
21 input. Unfortunately, there doesn't seem to be a "built-in" way of
22 printing to stderr other than using the pseudo-device.
24 END {
25 print "+", a > "/dev/stderr"
26 print "-", m > "/dev/stderr"
27 }
29 some example usages:
31 * cvs -q di | diffstat | tee /tmp/diff | less
32 * git diff | diffstat > /tmp/diff
33 * got di | diffstat | ssh foo 'cd xyz && got patch'