1

The following bash script (found elsewhere on StackOverflow) can compute the words changed in a git repo since the last commit:

# https://stackoverflow.com/questions/2874318/quantifying-the-amount-of-change-in-a-git-diff function git_words_added { revision=${1:-origin/master} git diff --word-diff=porcelain $revision | \ grep -e "^+[^+]" | \ wc -w | \ xargs } function git_words_removed { revision=${1:-origin/master} git diff --word-diff=porcelain $revision | \ grep -e "^-[^-]" | \ wc -w | \ xargs } function words_changed() { echo "(+"$(git_words_added $1)", -"$(git_words_removed $1)")" } 

The words_changed command is very handy for checking daily progress in writing.

Problem: The preceeding commands only show the difference between the working repo and the last commit. Is there a way to instead show the aggregate difference between all commits AND unstaged changes over a time period (say 24 hours)? So for example if 23 hours ago I add 10 words and delete 10 words (and commit), and then right now I add another 10 words and delete another 10 words (but don't yet commit or stage changes), how can I adjust the script to show (+20, -20) words changed instead of just (+10, -10)?

(I'm ignoring the problem of assessing whether the changes overlap and am assuming they are mutually exclusive).

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.