I want to limit the storage of a git repository, to avoid a repository exceed a size limit. I've seen this question (How to prevent a Git repository growing above a maximum size?), in which this problem is solved using a pre-receive hook. But, if I lock the push as this way, the user will cannot remove files to recover space.
I've thinking in modify this pre-receive, calculating a estimation of the size of the repository after the push. But I don't know how can I get this new size. This estimation must consider the removed files, to allow the user can do a new push removing files to leave space.
Other way could be use a post-receive, which revert the changes if the new size exceed the limit. But, if the push includes more than one commit, this revert can be complex.
How can I solve this?