Quantifying the amount of change in a git diff?

Posted by Alex Feinman on Stack Overflow See other posts from Stack Overflow or by Alex Feinman
Published on 2010-05-20T13:50:00Z Indexed on 2010/05/20 13:50 UTC
Read the original article Hit count: 200

Filed under:
|

I use git for a slightly unusual purpose--it stores my text as I write fiction. (I know, I know...geeky.)

I am trying to keep track of productivity, and want to measure the degree of difference between subsequent commits. The writer's proxy for "work" is "words written", at least during the creation stage. I can't use straight word count as it ignores editing and compression, both vital parts of writing. I think I want to track:

 (words added)+(words removed)

which will double-count (words changed), but I'm okay with that.

It'd be great to type some magic incantation and have git report this distance metric for any two revisions. However, git diffs are patches, which show entire lines even if you've only twiddled one character on the line; I don't want that, especially since my 'lines' are paragraphs. Ideally I'd even be able to specify what I mean by "word" (though \W+ would probably be acceptable).

Is there a flag to git-diff to give diffs on a word-by-word basis? Alternately, is there a solution using standard command-line tools to compute the metric above?

© Stack Overflow or respective owner

Related posts about git

Related posts about wordcount