Is it possible to show the total file size difference between two commits? Something like:
$ git file-size-diff 7f3219 bad418 # I wish this worked :)
-1234 bytes
I’ve tried:
$ git diff --patch-with-stat
And that shows the file size difference for each binary file in the diff — but not for text files, and not the total file size difference.
Any ideas?
git cat-file -swill output the size in bytes of an object in git.git diff-treecan tell you the differences between one tree and another.Putting this together into a script called
git-file-size-difflocated somewhere on your PATH will give you the ability to callgit file-size-diff <tree-ish> <tree-ish>. We can try something like the following:In use this looks like the following:
By using
git-rev-parseit should accept all the usual ways of specifying commit ranges.EDIT: updated to record the cumulative total. Note that bash runs the while read in a subshell, hence the additional curly braces to avoid losing the total when the subshell exits.
EDIT: added support for comparing the index against another tree-ish by using a
--cachedargument to callgit diff-indexinstead ofgit diff-tree. eg:EDIT: Mark script as capable of running in a subdirectory of a git repository.