{"thread":{"id":"28839","subject":"Find the size of git push in pre-receive hook","startedAt":"2011-11-04T09:20:20Z","lastAt":"2011-11-08T05:41:14Z","messageCount":5,"participants":["manigandans","Magnus Bäck","Junio C Hamano","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"178816","messageId":"1320398420796-6962141.post@n2.nabble.com","threadId":"28839","inReplyTo":null,"subject":"Find the size of git push in pre-receive hook","fromName":"manigandans","fromEmail":"etc.mani@gmail.com","sentAt":"2011-11-04T09:20:20Z","receivedAt":"2011-11-04T09:20:20Z","isPatch":false,"sender":{"key":"etc.mani@gmail.com","avatar":null},"body":"Hi,\n\nI want to restrict the size of the push on the git remote repository. How\ncan I find the size of the push in pre-receive hook?\n\nThanks a lot in advance.\n\nBest regards,\nManigandan S.\n\n\n--\nView this message in context: http://git.661346.n2.nabble.com/Find-the-size-of-git-push-in-pre-receive-hook-tp6962141p6962141.html\nSent from the git mailing list archive at Nabble.com.\n"},{"id":"178818","messageId":"20111104094644.GA31856@jpl.local","threadId":"28839","inReplyTo":"1320398420796-6962141.post@n2.nabble.com","subject":"Re: Find the size of git push in pre-receive hook","fromName":"Magnus Bäck","fromEmail":"magnus.back@sonyericsson.com","sentAt":"2011-11-04T09:46:44Z","receivedAt":"2011-11-04T09:46:44Z","isPatch":false,"sender":{"key":"magnus.back@sonyericsson.com","avatar":null},"body":"On Friday, November 04, 2011 at 10:20 CET,\n     manigandans <etc.mani@gmail.com> wrote:\n\n> I want to restrict the size of the push on the git remote repository.\n> How can I find the size of the push in pre-receive hook?\n\nWhat does \"size of the push\" mean to you? Number of bytes transmitted\nover the wire? Number of commits pushed? Number of refs updated? Number\nof files modified? Number of lines modified? Something else?\n\n-- \nMagnus Bäck                   Opinions are my own and do not necessarily\nSW Configuration Manager      represent the ones of my employer, etc.\nSony Ericsson\n"},{"id":"178845","messageId":"7vaa8bdax2.fsf@alter.siamese.dyndns.org","threadId":"28839","inReplyTo":"1320398420796-6962141.post@n2.nabble.com","subject":"Re: Find the size of git push in pre-receive hook","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-11-04T18:01:29Z","receivedAt":"2011-11-04T18:01:29Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"manigandans <etc.mani@gmail.com> writes:\n\n> I want to restrict the size of the push on the git remote repository. How\n> can I find the size of the push in pre-receive hook?\n\nYou don't.\n\nWhat are you trying to solve?\n\nThe thing is, by the time pre-receive-hook is run, the packs have already\nbeen transferred to the destination. Otherwise pre-receive-hook cannot do\nits primary task of inspecting the history the push is trying to update\nthe refs with and allow or deny the ref updates.\n\nPresumably you could run \"git rev-list --objects\" between the values of\nrefs before and after the proposed updates, sum up their sizes and reject\nthe push when the push adds too much data for your liking, and the next gc\nwill clean things up, but if your goal is to cap the maximum disk quota\nincluding the transient use during the time pre-receive-hook is run, it\nwould not help.\n"},{"id":"179000","messageId":"7vboso4hf6.fsf@alter.siamese.dyndns.org","threadId":"28839","inReplyTo":"CAFx4vfb-ssFXFEy9We7U+5+Fi+QsbcckNOEh1eXbMiqNfkU7jQ@mail.gmail.com","subject":"Re: Find the size of git push in pre-receive hook","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-11-07T05:42:37Z","receivedAt":"2011-11-07T05:42:37Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Manigandan S <etc.mani@gmail.com> writes:\n\n> Let me explain it in detail, if I was not clear.\n\nDo not top-post on this list.\n\nYou said you wanted to restrict the size of a push, but what you are\ntrying is to restrict the size of a repository after a push. If accepting\nthis push will result in your repository go over the quota, the push will\nbe denied. Otherwise the push will be accepted.\n\nIf that is the case, how much the resulting repository weighs is what you\nare trying to measure, not the size of _this_ push, i.e. the amount of\nadditional data this push will introduce, and \"du -s\" for the repository\ninside pre-receive-hook is the way to do so.\n"},{"id":"179122","messageId":"20111108054114.GB29643@sigill.intra.peff.net","threadId":"28839","inReplyTo":"7vboso4hf6.fsf@alter.siamese.dyndns.org","subject":"Re: Find the size of git push in pre-receive hook","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2011-11-08T05:41:14Z","receivedAt":"2011-11-08T05:41:14Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Nov 06, 2011 at 09:42:37PM -0800, Junio C Hamano wrote:\n\n> Manigandan S <etc.mani@gmail.com> writes:\n> \n> > Let me explain it in detail, if I was not clear.\n> \n> Do not top-post on this list.\n> \n> You said you wanted to restrict the size of a push, but what you are\n> trying is to restrict the size of a repository after a push. If accepting\n> this push will result in your repository go over the quota, the push will\n> be denied. Otherwise the push will be accepted.\n> \n> If that is the case, how much the resulting repository weighs is what you\n> are trying to measure, not the size of _this_ push, i.e. the amount of\n> additional data this push will introduce, and \"du -s\" for the repository\n> inside pre-receive-hook is the way to do so.\n\nI'm not sure even \"du -s\" is a good method. That will tell you how big\nthis push is right _now_, which is at least a maximum. But most commits,\nwhen packed with other commits, will take up a fraction of that space\ndue to deltas.\n\nSo you might receive a 100K thin pack on the network that git will\nexplode to a 5 megabyte full pack on disk. Next time you repack, it will\nonly increase the size of your existing packed data by 100K or so.\n\nIf receive-pack actually measured the incoming pack bytes in the thin\npack, that would probably be a more accurate guess (but again, it's\nstill just a guess).\n\n-Peff\n"}]}