Quantifying the amount of change in a git diff?

前端 未结 9 2037
不思量自难忘°
不思量自难忘° 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:34

    wdiff does word-by-word comparison. Git can be configured to use an external program to do the diffing. Based on those two facts and this blog post, the following should do roughly what you want.

    Create a script to ignore most of the unnecessary arguments that git-diff provides and pass them to wdiff. Save the following as ~/wdiff.py or something similar and make it executable.

    #!/usr/bin/python
    
    import sys
    import os
    
    os.system('wdiff -s3 "%s" "%s"' % (sys.argv[2], sys.argv[5]))
    

    Tell git to use it.

    git config --global diff.external ~/wdiff.py
    git diff filename
    

提交回复
热议问题