0

For example consider a git repository having 5 commits with size 1Mb, 2Mb, 2.5Mb, 3Mb and 2Mb at each of the commits. I wish to obtain the difference of each commit size in python. That is 1Mb, 1Mb, 0.5Mb, 0.5Mb, -1Mb.

Is there any way or command in python wherein I could calculate the size of the repository at each commit, and then I could simply subtract each subsequent entry to obtain the difference, or a direct command to do so.

I am using gitpython from a python script to perform git operations.

Tavish Jain
  • 155
  • 1
  • 2
  • 13
  • Start here, I think: https://stackoverflow.com/a/42544963/7976758 Search: https://stackoverflow.com/search?q=%5Bgit%5D+object+size – phd Dec 23 '19 at 09:37
  • You really need to define "commit size" first, because the size of the individual files stored *in* a commit is not the same as the size of the Git *blob objects* that contain those files' data, and if and when those objects are compressed into a Git pack file, they end up some *third* size. Without a clear definition of the "size of a commit", no one can ever agree that your code is correct. – torek Dec 23 '19 at 16:40
  • Related: https://stackoverflow.com/q/8646517/1256452 – torek Dec 23 '19 at 16:42
  • @torek by commit size I mean the size of the repo at any particular given commit. Meaning if I checkout at any given commit, what was the size of the repo at that time. Moreover the link you provided gives me the size of repo. – Tavish Jain Dec 23 '19 at 16:44
  • That size may change suddenly. For instance, try creating the first few commits above, then run `du -h ,git` (assuming Linux-y system), then run `git gc`, then run `du -h .git` again. (If you are sending files to some upstream Git, they'll get packed more quickly and you won't see as many size transitions like this.) – torek Dec 23 '19 at 16:46
  • https://interrupt.memfault.com/blog/code-size-deltas – Tedi May 13 '20 at 19:58

0 Answers0