The following bash script can compute the LOC change in a git repo in the previous 24 hours:
loc_changed() { since=${1:-24 hours} author=${2:[email protected]} git log --numstat --pretty="%H" --author="$author" --since="$since" | awk 'NF==3 {plus+=$1; minus+=$2} END {printf("(+%d, -%d) LOC\n", plus, minus)}' } Problem: This command excludes unstaged LOC changes. I think it would be useful to add unstaged changes to this LOC count. How does one do this?
Basically, what I am trying to achieve is this: given a repo, how much changed in the past 24 hours (irrespective of whether those changes have been staged or even committed yet)?
git loglooks only at commits. Neither the index contents, nor the work-tree contents, are commits. You can use some of thegit difffamily of commands that compare from or to the index and/or from/to the work-tree (you'll need one command for HEAD-to-index, then one for index-to-work-tree, for instance, to get staged and unstaged), or else make two commits out of index and work-tree. Or, you can make commits out of these. However, if the index contains an in-progress merge, it's not possible to commit it and overly difficult to diff against it.git diff-indexplumbing command.