I've added a git alias to give me the line counts of specific files in my history:
[alias]
lines = !lc() { git ls-files -z ${1} | xargs -0 wc -l; }; lc
However, wc -l
is reporting multiple totals, such that if I have more than ~100k lines, it reports the total for them, then moves on. Here's an example:
<100k lines (desired output)
$ git lines \*.xslt
46 packages/NUnit-2.5.10.11092/doc/files/Summary.xslt
232 packages/NUnit-2.5.10.11092/samples/csharp/_UpgradeReport_Files/UpgradeReport.xslt
278 total
>100k lines (had to pipe to grep "total"
)
$ git lines \*.cs | grep "total"
123569 total
107700 total
134796 total
111411 total
44600 total
How do I get a true total from wc -l
, not a series of subtotals?
xargs
, notwc
. I'm still interested in how to fix it, and I don't see a good solution in the answers. – Ehryk Jan 31 '14 at 19:49wc
support the--files0-from
option? Then you can do{ git ls-files -z ${1} | wc -l --files0-from=- ; }
– Mark Plotnick Jan 31 '14 at 20:40wc: unrecognized option '--files0-from=-'
– Ehryk Jan 31 '14 at 21:39