Re: Find the size of git push in pre-receive hook
On Sun, Nov 06, 2011 at 09:42:37PM -0800, Junio C Hamano wrote:
Show 15 quoted lines
> Manigandan S <etc.mani@gmail.com> writes:
>
> > Let me explain it in detail, if I was not clear.
>
> Do not top-post on this list.
>
> You said you wanted to restrict the size of a push, but what you are
> trying is to restrict the size of a repository after a push. If accepting
> this push will result in your repository go over the quota, the push will
> be denied. Otherwise the push will be accepted.
>
> If that is the case, how much the resulting repository weighs is what you
> are trying to measure, not the size of _this_ push, i.e. the amount of
> additional data this push will introduce, and "du -s" for the repository
> inside pre-receive-hook is the way to do so.
I'm not sure even "du -s" is a good method. That will tell you how big this push is right _now_, which is at least a maximum. But most commits, when packed with other commits, will take up a fraction of that space due to deltas.
So you might receive a 100K thin pack on the network that git will explode to a 5 megabyte full pack on disk. Next time you repack, it will only increase the size of your existing packed data by 100K or so.
If receive-pack actually measured the incoming pack bytes in the thin pack, that would probably be a more accurate guess (but again, it's still just a guess).
-Peff