Quantifying the amount of change in a git diff?

前端 未结 9 2036
不思量自难忘°
不思量自难忘° 2020-12-13 17:38

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 meas

9条回答
  •  一整个雨季
    2020-12-13 18:24

    Git has had (for a long time) a --color-words option for git diff. This doesn't get you your counting, but it does let you see the diffs.

    scompt.com's suggestion of wdiff is also good; it's pretty easy to shove in a different differ (see git-difftool). From there you just have to go from the output wdiff can give to the result you really want.

    There's one more exciting thing to share, though, from git's what's cooking:

    * tr/word-diff (2010-04-14) 1 commit
      (merged to 'next' on 2010-05-04 at d191b25)
     + diff: add --word-diff option that generalizes --color-words
    

    Here's the commit introducing word-diff. Presumably it will make its way from next into master before long, and then git will be able to do this all internally - either producing its own word diff format or something similar to wdiff. If you're daring, you could build git from next, or just merge that one commit into your local master to build.

    Thanks to Jakub's comment: you can further customize word diffs if necessary by providing a word regex (config parameter diff.*.wordRegex), documented in gitattributes.

提交回复
热议问题