This seemed to be roughly three times slower than a direct "wc -l" from working tree, but this way we are not limited to full & clean working trees, but can also handle bare repositories.