{"thread":{"id":"24218","subject":"notify alternative to auto gc?","startedAt":"2010-06-28T16:10:40Z","lastAt":"2010-09-21T23:18:54Z","messageCount":21,"participants":["Karl Stenerud","Ævar Arnfjörð Bjarmason","Chris Packham","Matthieu Moy","Marc Branchaud","Eric Raible","Jacob Helwig","Junio C Hamano","Sam Vilain","David Brown"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"144391","messageId":"EA7717AE-DA72-48D7-A27E-C958896FD158@gmail.com","threadId":"24218","inReplyTo":null,"subject":"notify alternative to auto gc?","fromName":"Karl Stenerud","fromEmail":"kstenerud@gmail.com","sentAt":"2010-06-28T16:10:40Z","receivedAt":"2010-06-28T16:10:40Z","isPatch":false,"sender":{"key":"kstenerud@gmail.com","avatar":"https://gravatar.com/avatar/92c72cb81051749f48f9ce94d71d3995a72623117e5939a97c263f87f00fbce5?d=mp&s=160"},"body":"Hi,\n\nAs I did a git pull on my project today, git went into some kind of auto gc mode:\n\nAuto packing the repository for optimum performance. You may also\nrun \"git gc\" manually. See \"git help gc\" for more information.\nCounting objects: 4531, done.\n\nThis is, of course, quite an annoying feature since it could hit at any (inconvenient) time.\n\nThe git help tells me I can disable it by setting gc.auto to 0, while the mailing list archive tells me I also have to set gc.autopacklimit to 0.  This is fine, but if I do that, I won't know when the repo is in need of cleanup.  Is there any option I can set to instruct it to simply TELL me when it's in need of gc?\n"},{"id":"144392","messageId":"AANLkTil8sHZrfvHetwzjhOsyprsqrf7-XRS3B8qKH7cs@mail.gmail.com","threadId":"24218","inReplyTo":"EA7717AE-DA72-48D7-A27E-C958896FD158@gmail.com","subject":"Re: notify alternative to auto gc?","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2010-06-28T16:26:01Z","receivedAt":"2010-06-28T16:26:01Z","isPatch":false,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"On Mon, Jun 28, 2010 at 16:10, Karl Stenerud <kstenerud@gmail.com> wrote:\n> The git help tells me I can disable it by setting gc.auto to 0, while the mailing list archive tells me I also have to set gc.autopacklimit to 0.  This is fine, but if I do that, I won't know when the repo is in need of cleanup.  Is there any option I can set to instruct it to simply TELL me when it's in need of gc?\n\nAnything that tells you whether you need to gc would incur much of the\nspeed penalty that running gc itself does.\n"},{"id":"144394","messageId":"vpqaaqfgm1j.fsf@bauges.imag.fr","threadId":"24218","inReplyTo":"EA7717AE-DA72-48D7-A27E-C958896FD158@gmail.com","subject":"Re: notify alternative to auto gc?","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2010-06-28T16:27:20Z","receivedAt":"2010-06-28T16:27:20Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Karl Stenerud <kstenerud@gmail.com> writes:\n\n> The git help tells me I can disable it by setting gc.auto to 0,\n> while the mailing list archive tells me I also have to set\n> gc.autopacklimit to 0.  This is fine, but if I do that, I won't know\n> when the repo is in need of cleanup.  Is there any option I can set\n> to instruct it to simply TELL me when it's in need of gc?\n\nAn alternative is to actually run \"git gc\" periodically, to make sure\nthat git gc --auto is never needed.\n\nI do that from a cron job for example.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"144393","messageId":"AANLkTikjbu_q6QToVUeNAAL0Fls9eQ5BZkzZ1-8L93zh@mail.gmail.com","threadId":"24218","inReplyTo":"EA7717AE-DA72-48D7-A27E-C958896FD158@gmail.com","subject":"Re: notify alternative to auto gc?","fromName":"Chris Packham","fromEmail":"judge.packham@gmail.com","sentAt":"2010-06-28T16:29:54Z","receivedAt":"2010-06-28T16:29:54Z","isPatch":false,"sender":{"key":"judge.packham@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155667?v=4"},"body":"On Mon, Jun 28, 2010 at 9:10 AM, Karl Stenerud <kstenerud@gmail.com> wrote:\n> Hi,\n>\n> As I did a git pull on my project today, git went into some kind of auto gc mode:\n>\n> Auto packing the repository for optimum performance. You may also\n> run \"git gc\" manually. See \"git help gc\" for more information.\n> Counting objects: 4531, done.\n>\n> This is, of course, quite an annoying feature since it could hit at any (inconvenient) time.\n>\n> The git help tells me I can disable it by setting gc.auto to 0, while the mailing list archive tells me I also have to set gc.autopacklimit to 0.  This is fine, but if I do that, I won't know when the repo is in need of cleanup.  Is there any option I can set to instruct it to simply TELL me when it's in need of gc?\n>\n\nI don't think there is an existing configuration for this but I think\nyou can achieve what you want with the \"pre-auto-gc\" hook. From the\ngithooks(5) man page\n\n  pre-auto-gc\n     This hook is invoked by git gc --auto. It takes no parameter, and\n     exiting with non-zero status from this script causes the git gc --auto\n     to abort.\n\nSo a hook like\n\n  #! /bin/sh\n  echo \"repository needs git gc\"\n  exit 1\n\nShould cause the auto gc to be skipped.\n"},{"id":"144395","messageId":"5D3639C2-2528-4125-91E0-8D78D4844511@gmail.com","threadId":"24218","inReplyTo":"AANLkTil8sHZrfvHetwzjhOsyprsqrf7-XRS3B8qKH7cs@mail.gmail.com","subject":"Re: notify alternative to auto gc?","fromName":"Karl Stenerud","fromEmail":"kstenerud@gmail.com","sentAt":"2010-06-28T16:52:13Z","receivedAt":"2010-06-28T16:52:13Z","isPatch":false,"sender":{"key":"kstenerud@gmail.com","avatar":"https://gravatar.com/avatar/92c72cb81051749f48f9ce94d71d3995a72623117e5939a97c263f87f00fbce5?d=mp&s=160"},"body":"\nOn 2010-06-28, at 12:26 PM, Ævar Arnfjörð Bjarmason wrote:\n\n> On Mon, Jun 28, 2010 at 16:10, Karl Stenerud <kstenerud@gmail.com> wrote:\n>> The git help tells me I can disable it by setting gc.auto to 0, while the mailing list archive tells me I also have to set gc.autopacklimit to 0.  This is fine, but if I do that, I won't know when the repo is in need of cleanup.  Is there any option I can set to instruct it to simply TELL me when it's in need of gc?\n> \n> Anything that tells you whether you need to gc would incur much of the\n> speed penalty that running gc itself does.\n\nActually, no it wouldn't.  If checking did incur much of the speed penalty, then git, in general, would already be horribly slow all the time because it automatically does a gc-check with most commonly used commands, according to the documentation.\n\nIn the case which I observed, the time from typing \"git pull\" until the auto-gc notification was a few seconds.  The time from the notification until gc completion, however, was 3-4 minutes.\n"},{"id":"144396","messageId":"ECC14D96-DAA0-4165-9FC5-43328504CE09@gmail.com","threadId":"24218","inReplyTo":"AANLkTikjbu_q6QToVUeNAAL0Fls9eQ5BZkzZ1-8L93zh@mail.gmail.com","subject":"Re: notify alternative to auto gc?","fromName":"Karl Stenerud","fromEmail":"kstenerud@gmail.com","sentAt":"2010-06-28T16:56:49Z","receivedAt":"2010-06-28T16:56:49Z","isPatch":false,"sender":{"key":"kstenerud@gmail.com","avatar":"https://gravatar.com/avatar/92c72cb81051749f48f9ce94d71d3995a72623117e5939a97c263f87f00fbce5?d=mp&s=160"},"body":"\nOn 2010-06-28, at 12:29 PM, Chris Packham wrote:\n\n> On Mon, Jun 28, 2010 at 9:10 AM, Karl Stenerud <kstenerud@gmail.com> wrote:\n>> Hi,\n>> \n>> As I did a git pull on my project today, git went into some kind of auto gc mode:\n>> \n>> Auto packing the repository for optimum performance. You may also\n>> run \"git gc\" manually. See \"git help gc\" for more information.\n>> Counting objects: 4531, done.\n>> \n>> This is, of course, quite an annoying feature since it could hit at any (inconvenient) time.\n>> \n>> The git help tells me I can disable it by setting gc.auto to 0, while the mailing list archive tells me I also have to set gc.autopacklimit to 0.  This is fine, but if I do that, I won't know when the repo is in need of cleanup.  Is there any option I can set to instruct it to simply TELL me when it's in need of gc?\n>> \n> \n> I don't think there is an existing configuration for this but I think\n> you can achieve what you want with the \"pre-auto-gc\" hook. From the\n> githooks(5) man page\n> \n>  pre-auto-gc\n>     This hook is invoked by git gc --auto. It takes no parameter, and\n>     exiting with non-zero status from this script causes the git gc --auto\n>     to abort.\n> \n> So a hook like\n> \n>  #! /bin/sh\n>  echo \"repository needs git gc\"\n>  exit 1\n> \n> Should cause the auto gc to be skipped.\n\n\nCool thanks!  I'll give that a shot.\n"},{"id":"144398","messageId":"1277744834-7546-1-git-send-email-judge.packham@gmail.com","threadId":"24218","inReplyTo":"AANLkTikjbu_q6QToVUeNAAL0Fls9eQ5BZkzZ1-8L93zh@mail.gmail.com","subject":"[PATCH/RFC] Documentation/git-gc.txt: add reference to githooks","fromName":"Chris Packham","fromEmail":"judge.packham@gmail.com","sentAt":"2010-06-28T17:07:14Z","receivedAt":"2010-06-28T17:07:14Z","isPatch":true,"sender":{"key":"judge.packham@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155667?v=4"},"body":"This advertises the existence of the 'pre-auto-gc' hook and adds a cross\nreference to where the hook is documented.\n\nSigned-off-by: Chris Packham <judge.packham@gmail.com>\n---\nI had to go fishing in the code to find out about the pre-auto-gc hook. From\nreading the git-gc man page it wasn't obvious to me that there would be a hook\nfor 'git gc --auto'. The relevant config variables are mentioned so it seems\nlogical to mention the hooks also. The only precedent I found for this was in\nthe git-commit man page which has a section listing the hooks that are\navailable.\n\n Documentation/git-gc.txt |    5 +++++\n 1 files changed, 5 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/git-gc.txt b/Documentation/git-gc.txt\nindex a9e0882..a514c52 100644\n--- a/Documentation/git-gc.txt\n+++ b/Documentation/git-gc.txt\n@@ -137,6 +137,11 @@ If you are expecting some objects to be collected and they aren't, check\n all of those locations and decide whether it makes sense in your case to\n remove those references.\n \n+HOOKS\n+-----\n+This command can run `pre-auto-gc` hook.  See linkgit:githooks[5] for more\n+information.\n+\n SEE ALSO\n --------\n linkgit:git-prune[1]\n-- \n1.7.1\n"},{"id":"144403","messageId":"4C28ED49.90906@xiplink.com","threadId":"24218","inReplyTo":"1277744834-7546-1-git-send-email-judge.packham@gmail.com","subject":"Re: [PATCH/RFC] Documentation/git-gc.txt: add reference to githooks","fromName":"Marc Branchaud","fromEmail":"marcnarc@xiplink.com","sentAt":"2010-06-28T18:43:21Z","receivedAt":"2010-06-28T18:43:21Z","isPatch":true,"sender":{"key":"marcnarc@xiplink.com","avatar":"https://avatars.githubusercontent.com/u/14980203?v=4"},"body":"How about also adding a templates/hooks--pre-auto-gc.sample file?\n\n\t\tM.\n\n\nOn 10-06-28 01:07 PM, Chris Packham wrote:\n> This advertises the existence of the 'pre-auto-gc' hook and adds a cross\n> reference to where the hook is documented.\n> \n> Signed-off-by: Chris Packham <judge.packham@gmail.com>\n> ---\n> I had to go fishing in the code to find out about the pre-auto-gc hook. From\n> reading the git-gc man page it wasn't obvious to me that there would be a hook\n> for 'git gc --auto'. The relevant config variables are mentioned so it seems\n> logical to mention the hooks also. The only precedent I found for this was in\n> the git-commit man page which has a section listing the hooks that are\n> available.\n> \n>  Documentation/git-gc.txt |    5 +++++\n>  1 files changed, 5 insertions(+), 0 deletions(-)\n> \n> diff --git a/Documentation/git-gc.txt b/Documentation/git-gc.txt\n> index a9e0882..a514c52 100644\n> --- a/Documentation/git-gc.txt\n> +++ b/Documentation/git-gc.txt\n> @@ -137,6 +137,11 @@ If you are expecting some objects to be collected and they aren't, check\n>  all of those locations and decide whether it makes sense in your case to\n>  remove those references.\n>  \n> +HOOKS\n> +-----\n> +This command can run `pre-auto-gc` hook.  See linkgit:githooks[5] for more\n> +information.\n> +\n>  SEE ALSO\n>  --------\n>  linkgit:git-prune[1]\n"},{"id":"144405","messageId":"loom.20100628T205729-213@post.gmane.org","threadId":"24218","inReplyTo":"AANLkTikjbu_q6QToVUeNAAL0Fls9eQ5BZkzZ1-8L93zh@mail.gmail.com","subject":"Re: notify alternative to auto gc?","fromName":"Eric Raible","fromEmail":"raible@gmail.com","sentAt":"2010-06-28T18:58:59Z","receivedAt":"2010-06-28T18:58:59Z","isPatch":false,"sender":{"key":"raible@gmail.com","avatar":null},"body":"Chris Packham <judge.packham <at> gmail.com> writes:\n\n> So a hook like\n> \n>   #! /bin/sh\n>   echo \"repository needs git gc\"\n>   exit 1\n> \n> Should cause the auto gc to be skipped.\n\nExcept wouldn't you also need a mechanism\nto allow an explicit gc to actually proceed?\n"},{"id":"144408","messageId":"AANLkTinGs3Nu-2hFcCSeEZBTT8OhfOG-iu4CNjdG62uS@mail.gmail.com","threadId":"24218","inReplyTo":"loom.20100628T205729-213@post.gmane.org","subject":"Re: notify alternative to auto gc?","fromName":"Jacob Helwig","fromEmail":"jacob.helwig@gmail.com","sentAt":"2010-06-28T19:02:35Z","receivedAt":"2010-06-28T19:02:35Z","isPatch":false,"sender":{"key":"jacob.helwig@gmail.com","avatar":"https://avatars.githubusercontent.com/u/14557?v=4"},"body":"On Mon, Jun 28, 2010 at 11:58, Eric Raible <raible@gmail.com> wrote:\n> Chris Packham <judge.packham <at> gmail.com> writes:\n>\n>> So a hook like\n>>\n>>   #! /bin/sh\n>>   echo \"repository needs git gc\"\n>>   exit 1\n>>\n>> Should cause the auto gc to be skipped.\n>\n> Except wouldn't you also need a mechanism\n> to allow an explicit gc to actually proceed?\n>\n\nOnly if you're explicitly calling \"git gc --auto\" instead of \"git gc\".\n That hook should only run for \"git gc --auto\".\n"},{"id":"144443","messageId":"vpqtyom72ug.fsf@bauges.imag.fr","threadId":"24218","inReplyTo":"5D3639C2-2528-4125-91E0-8D78D4844511@gmail.com","subject":"Re: notify alternative to auto gc?","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2010-06-29T06:46:47Z","receivedAt":"2010-06-29T06:46:47Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Karl Stenerud <kstenerud@gmail.com> writes:\n\n> In the case which I observed, the time from typing \"git pull\" until\n> the auto-gc notification was a few seconds.  The time from the\n> notification until gc completion, however, was 3-4 minutes.\n\nThe missing bit here is how often this happens.\n\nOnce you did an actual \"git gc\", your repository is stored in a single\npack file, and only new files are stored unpacked or in separate\npacks. Subsequent \"git gc --auto\" will just pack unpacked objects\ntogether by groups of approximately \"gc.auto\" (i.e. 6700), which is\nquick, until you reach \"gc.packlimit\" (i.e. 50). You'll trigger an\nexpansive repack only after that. So, roughly, you'll get an expansive\nrepack after creating 300,000 object files (unless you ran \"git gc\" in\nthe meantime). Unless you do very nasty things with your repo, that\nreally means \"not often\", and especially \"not often enough that you\nshould care\" in 99.9% cases.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"144466","messageId":"7vsk45c09m.fsf@alter.siamese.dyndns.org","threadId":"24218","inReplyTo":"4C28ED49.90906@xiplink.com","subject":"Re: [PATCH/RFC] Documentation/git-gc.txt: add reference to githooks","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-06-29T15:43:33Z","receivedAt":"2010-06-29T15:43:33Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Marc Branchaud <marcnarc@xiplink.com> writes:\n\n> How about also adding a templates/hooks--pre-auto-gc.sample file?\n\nPlease don't, as samples are propagated to all newly created repositories.\n"},{"id":"144468","messageId":"AANLkTilZsHJ20hGehY5eqOfS8jt--ne_QGp4z8SyNeUD@mail.gmail.com","threadId":"24218","inReplyTo":"7vsk45c09m.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH/RFC] Documentation/git-gc.txt: add reference to githooks","fromName":"Chris Packham","fromEmail":"judge.packham@gmail.com","sentAt":"2010-06-29T16:00:29Z","receivedAt":"2010-06-29T16:00:29Z","isPatch":true,"sender":{"key":"judge.packham@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155667?v=4"},"body":"On Tue, Jun 29, 2010 at 8:43 AM, Junio C Hamano <gitster@pobox.com> wrote:\n> Marc Branchaud <marcnarc@xiplink.com> writes:\n>\n>> How about also adding a templates/hooks--pre-auto-gc.sample file?\n>\n> Please don't, as samples are propagated to all newly created repositories.\n>\n\nOK. I won't add a sample hook.\n"},{"id":"144470","messageId":"7vfx05by9t.fsf@alter.siamese.dyndns.org","threadId":"24218","inReplyTo":"1277744834-7546-1-git-send-email-judge.packham@gmail.com","subject":"Re: [PATCH/RFC] Documentation/git-gc.txt: add reference to githooks","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-06-29T16:26:38Z","receivedAt":"2010-06-29T16:26:38Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Chris Packham <judge.packham@gmail.com> writes:\n\n> +HOOKS\n> +-----\n> +This command can run `pre-auto-gc` hook.  See linkgit:githooks[5] for more\n> +information.\n\nHmm.  \"git gc --auto\" does, but \"git gc\" doesn't, and saying \"can run\"\nonly adds to the sense of incompleteness of the description here without\ngiving useful information to the reader (iow, the user will have to check\nthe referred-to page anyway).  We would need to either remove the first\nsentence (leaving only \"See ... for information\") or clarify the first\nsentence a bit better, I think.\n"},{"id":"144480","messageId":"4C2A3889.90407@gmail.com","threadId":"24218","inReplyTo":"7vfx05by9t.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH/RFC] Documentation/git-gc.txt: add reference to githooks","fromName":"Chris Packham","fromEmail":"judge.packham@gmail.com","sentAt":"2010-06-29T18:16:41Z","receivedAt":"2010-06-29T18:16:41Z","isPatch":true,"sender":{"key":"judge.packham@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155667?v=4"},"body":"On 29/06/10 09:26, Junio C Hamano wrote:\n> Chris Packham <judge.packham@gmail.com> writes:\n>   \n>> +HOOKS\n>> +-----\n>> +This command can run `pre-auto-gc` hook.  See linkgit:githooks[5] for more\n>> +information.\n>>     \n> Hmm.  \"git gc --auto\" does, but \"git gc\" doesn't, and saying \"can run\"\n> only adds to the sense of incompleteness of the description here without\n> giving useful information to the reader (iow, the user will have to check\n> the referred-to page anyway).  We would need to either remove the first\n> sentence (leaving only \"See ... for information\") or clarify the first\n> sentence a bit better, I think.\n>   \nHow about\n\nThe `git gc --auto` command will run the `pre-auto-gc` hook, if\nenabled.  See linkgit:githooks[5] for more information.\n"},{"id":"144492","messageId":"1277864838.23613.18.camel@wilber","threadId":"24218","inReplyTo":"AANLkTil8sHZrfvHetwzjhOsyprsqrf7-XRS3B8qKH7cs@mail.gmail.com","subject":"Re: notify alternative to auto gc?","fromName":"Sam Vilain","fromEmail":"sam@vilain.net","sentAt":"2010-06-30T02:27:18Z","receivedAt":"2010-06-30T02:27:18Z","isPatch":false,"sender":{"key":"sam@vilain.net","avatar":"https://gravatar.com/avatar/8fc840ca854dbf6f7065b4335e3b934951c1dca3b11db688e95e471901f8f4a8?d=mp&s=160"},"body":"On Mon, 2010-06-28 at 16:26 +0000, Ævar Arnfjörð Bjarmason wrote:\n> On Mon, Jun 28, 2010 at 16:10, Karl Stenerud <kstenerud@gmail.com> wrote:\n> > The git help tells me I can disable it by setting gc.auto to 0, while the mailing list archive tells me I also have to set gc.autopacklimit to 0.  This is fine, but if I do that, I won't know when the repo is in need of cleanup.  Is there any option I can set to instruct it to simply TELL me when it's in need of gc?\n> \n> Anything that tells you whether you need to gc would incur much of the\n> speed penalty that running gc itself does.\n\nSee builtin/gc.c:too_many_loose_objects\n\nChecking that gc is required involves opening one directory (objects/17\nIIRC), reading all of the entries in it and counting them.  It really\ndoesn't hurt.\n\nSam\n"},{"id":"144552","messageId":"1277930487-13831-1-git-send-email-judge.packham@gmail.com","threadId":"24218","inReplyTo":"4C2A3889.90407@gmail.com","subject":"[PATCHv2] Documentation/git-gc.txt: add reference to githooks","fromName":"Chris Packham","fromEmail":"judge.packham@gmail.com","sentAt":"2010-06-30T20:41:27Z","receivedAt":"2010-06-30T20:41:27Z","isPatch":false,"sender":{"key":"judge.packham@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155667?v=4"},"body":"This advertises the existence of the 'pre-auto-gc' hook and adds a cross\nreference to where the hook is documented.\n\nSigned-off-by: Chris Packham <judge.packham@gmail.com>\n---\n\nI removed the ',if enabled' part from what I suggested on the list. It never\ndid read quite right to me and I think it just adds confusion to what should be\na simple sentence.\n\n Documentation/git-gc.txt |    7 +++++++\n 1 files changed, 7 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/git-gc.txt b/Documentation/git-gc.txt\nindex a9e0882..315f07e 100644\n--- a/Documentation/git-gc.txt\n+++ b/Documentation/git-gc.txt\n@@ -137,6 +137,13 @@ If you are expecting some objects to be collected and they aren't, check\n all of those locations and decide whether it makes sense in your case to\n remove those references.\n \n+HOOKS\n+-----\n+\n+The 'git gc --auto' command will run the 'pre-auto-gc' hook.  See\n+linkgit:githooks[5] for more information.\n+\n+\n SEE ALSO\n --------\n linkgit:git-prune[1]\n-- \n1.7.1\n"},{"id":"151229","messageId":"20100921181406.GA7389@huya.qualcomm.com","threadId":"24218","inReplyTo":"1277744834-7546-1-git-send-email-judge.packham@gmail.com","subject":"Re: [PATCH/RFC] Documentation/git-gc.txt: add reference to githooks","fromName":"David Brown","fromEmail":"davidb@codeaurora.org","sentAt":"2010-09-21T18:14:06Z","receivedAt":"2010-09-21T18:14:06Z","isPatch":true,"sender":{"key":"davidb@codeaurora.org","avatar":"https://gravatar.com/avatar/1bacedec21621bd4efa4bc8ecb05c507f0cf0641ecdaa50943c2ed21c8ef22d8?d=mp&s=160"},"body":"Suppose I want to publish some changes to a tree.  I have a server\navailable where I can run a git daemon, but for one reason or another\nI want to force people to use the another git repo as a reference.\nThe reason could be one of bandwidth, or someone who isn't comfortable\nmaking all of the other source available.  Ideally, someone who\nalready has the other git repo cloned, and just adds mine as a remote\nwouldn't notice the difference.\n\nIs there a way to do this?  I've tried various ways of using\nalternates to keep the blobs out of the repository I want to export,\nbut the daemon just follows the alternates.  If I remove the\nalternates, I then seem to have a broken repository.  Most things I\ntry, at least carry objects for all of the files in the HEAD tree,\nwhich most of the time is a large portion of the data.\n\nIf there isn't a way of doing this currently, is this something that\nothers would find useful?\n\nThanks,\nDavid\n\n-- \nSent by an employee of the Qualcomm Innovation Center, Inc.\nThe Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum.\n"},{"id":"151250","messageId":"4C991B29.4030208@gmail.com","threadId":"24218","inReplyTo":"20100921181406.GA7389@huya.qualcomm.com","subject":"Re: Allow git remote add but not git clone ( was Re: [PATCH/RFC] Documentation/git-gc.txt: add reference to githooks)","fromName":"Chris Packham","fromEmail":"judge.packham@gmail.com","sentAt":"2010-09-21T20:52:57Z","receivedAt":"2010-09-21T20:52:57Z","isPatch":true,"sender":{"key":"judge.packham@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155667?v=4"},"body":"On 21/09/10 11:14, David Brown wrote:\n> Subject: Re: [PATCH/RFC] Documentation/git-gc.txt: add reference to githooks\n\nWow odd thread to pickup. Hopefully someone that knows more than me will\nnotice the change of subject an provide a better answer.\n\n> Suppose I want to publish some changes to a tree.  I have a server\n> available where I can run a git daemon, but for one reason or another\n> I want to force people to use the another git repo as a reference.\n> The reason could be one of bandwidth, or someone who isn't comfortable\n> making all of the other source available.  Ideally, someone who\n> already has the other git repo cloned, and just adds mine as a remote\n> wouldn't notice the difference.\n\nSounds like a reasonable motivation.\n\n> Is there a way to do this?\n\nAs far as I know no. The mechanisms that git clone and git remote\nadd/git fetch are fairly generic so I doubt there is a way for the git\ndaemon to know which was run by the user at the other end. Maybe there\nare other possible solutions outside of git to but a cap the amount of\ndata sent. Doesn't look like there are any hooks on the upload-pack side\nof git daemon.\n\n> If there isn't a way of doing this currently, is this something that\n> others would find useful?\n\nI personally wouldn't but I can see why some people might want this.\n"},{"id":"151253","messageId":"20100921210141.GA25502@huya.qualcomm.com","threadId":"24218","inReplyTo":"4C991B29.4030208@gmail.com","subject":"Re: Allow git remote add but not git clone ( was Re: [PATCH/RFC] Documentation/git-gc.txt: add reference to githooks)","fromName":"David Brown","fromEmail":"davidb@codeaurora.org","sentAt":"2010-09-21T21:01:41Z","receivedAt":"2010-09-21T21:01:41Z","isPatch":true,"sender":{"key":"davidb@codeaurora.org","avatar":"https://gravatar.com/avatar/1bacedec21621bd4efa4bc8ecb05c507f0cf0641ecdaa50943c2ed21c8ef22d8?d=mp&s=160"},"body":"On Tue, Sep 21, 2010 at 01:52:57PM -0700, Chris Packham wrote:\n> On 21/09/10 11:14, David Brown wrote:\n> > Subject: Re: [PATCH/RFC] Documentation/git-gc.txt: add reference to githooks\n> \n> Wow odd thread to pickup. Hopefully someone that knows more than me will\n> notice the change of subject an provide a better answer.\n\nYeah, I sent another message with an entirely new subject and new\nthread so that hopefully people will see it.  This one can just die.\n\nDavid\n"},{"id":"151259","messageId":"7vtyliu1lt.fsf_-_@alter.siamese.dyndns.org","threadId":"24218","inReplyTo":"20100921181406.GA7389@huya.qualcomm.com","subject":"Re* [PATCH/RFC] Documentation/git-gc.txt: add reference to githooks","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-09-21T23:18:54Z","receivedAt":"2010-09-21T23:18:54Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"David Brown <davidb@codeaurora.org> writes:\n\n> Suppose I want to publish some changes to a tree.  I have a server\n> available where I can run a git daemon, but for one reason or another\n> I want to force people to use the another git repo as a reference.\n> The reason could be one of bandwidth, or someone who isn't comfortable\n> making all of the other source available.  Ideally, someone who\n> already has the other git repo cloned, and just adds mine as a remote\n> wouldn't notice the difference.\n>\n> Is there a way to do this?  I've tried various ways of using\n> alternates to keep the blobs out of the repository I want to export,\n> but the daemon just follows the alternates.  If I remove the\n> alternates, I then seem to have a broken repository.  Most things I\n> try, at least carry objects for all of the files in the HEAD tree,\n> which most of the time is a large portion of the data.\n\nI've seen people ask for something like this in the past for a few times.\nOnce might have been during GitTogether'08 by you.\n\nI don't think there is a way to do that, though.\n\nPerhaps something like this totally untested patch?  The code may be\nutterly wrong but you should be able to get the idea from the test\nscripts.  Add configuration to the repository for you to declare which\nobjects are prerequiste for pulling from you, with a message to suggest\nwhere to grab them from.\n\nI am a bit reluctant to suggest upload-pack to start reading from the\nrepository configuration, though.\n\n t/t5532-upload-limit.sh |  107 +++++++++++++++++++++++++++++++++++++++++\n upload-pack.c           |  120 +++++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 227 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t5532-upload-limit.sh b/t/t5532-upload-limit.sh\nnew file mode 100755\nindex 0000000..070594e\n--- /dev/null\n+++ b/t/t5532-upload-limit.sh\n@@ -0,0 +1,107 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2010 Google Inc.\n+#\n+\n+test_description='git upload-pack honoring clonelimit configuration'\n+\n+. ./test-lib.sh\n+\n+grow () {\n+\tfor a\n+\tdo\n+\t\techo \"$a\" >file &&\n+\t\tgit add file &&\n+\t\tgit commit -m \"$a\" || exit\n+\tdone\n+}\n+\n+setup_clone () {\n+\tgit clone \"file://$(pwd)/src\" \"$1\" &&\n+\t(\n+\t\tcd \"$1\" &&\n+\t\tgit rev-parse --verify \"$2\" >actual\n+\t) &&\n+\ttest_cmp src/expect \"$1/actual\"\n+}\n+\n+test_expect_success 'setup' '\n+\tmkdir src &&\n+\t(\n+\t\tcd src &&\n+\t\tgit init &&\n+\t\tgrow a b c &&\n+\t\tgit rev-parse --verify master >expect\n+\t) &&\n+\tsetup_clone dst-0 master &&\n+\tsetup_clone dst-1 master &&\n+\t(\n+\t\tcd src &&\n+\t\tgrow d e &&\n+\t\tgit tag -a -m mark mark &&\n+\t\tgit rev-parse --verify mark >expect\n+\t) &&\n+\tsetup_clone dst-2 mark &&\n+\tsetup_clone dst-3 mark &&\n+\t(\n+\t\tcd src &&\n+\t\tgrow f g h &&\n+\t\tgit tag -a -m tip tip &&\n+\t\tgit rev-parse --verify tip >expect\n+\t)\n+'\n+\n+test_expect_success 'baseline - no limitation in fetch' '\n+\t(\n+\t\tcd dst-0 &&\n+\t\tgit fetch &&\n+\t\tgit rev-parse --verify tip >actual\n+\t) &&\n+\ttest_cmp src/expect dst-0/actual\n+'\n+\n+test_expect_success 'clone refused when limitation is set' '\n+\t(\n+\t\tcd src &&\n+\t\tgit config clonelimit.mark.message \"go away\"\n+\t) &&\n+\ttest_must_fail git clone \"file://$(pwd)/src\" dst-4 &&\n+\t! test -d dst-4\n+'\n+\n+test_expect_success 'fetch refused when limitation is unmet' '\n+\t(\n+\t\tcd dst-1 &&\n+\t\ttest_must_fail git fetch &&\n+\t\ttest_must_fail git rev-parse --verify tip\n+\t)\n+'\n+\n+test_expect_success 'fetch works when limitation is met' '\n+\t(\n+\t\tcd src &&\n+\t\tgit config clonelimit.mark.message \"go away\"\n+\t) &&\n+\t(\n+\t\tcd dst-2 &&\n+\t\tgit fetch &&\n+\t\tgit rev-parse --verify tip >actual\n+\t) &&\n+\ttest_cmp src/expect dst-2/actual\n+'\n+\n+test_expect_success 'missing tag is not a limitation violation' '\n+\t(\n+\t\tcd src &&\n+\t\tgit config clonelimit.mark.message \"go away\"\n+\t) &&\n+\t(\n+\t\tcd dst-3 &&\n+\t\tgit tag -d mark &&\n+\t\tgit fetch &&\n+\t\tgit rev-parse --verify tip >actual\n+\t) &&\n+\ttest_cmp src/expect dst-3/actual\n+'\n+\n+test_done\ndiff --git a/upload-pack.c b/upload-pack.c\nindex 92f9530..9d4a367 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -655,6 +655,124 @@ static int mark_our_ref(const char *refname, const unsigned char *sha1, int flag\n \treturn 0;\n }\n \n+/*\n+ * Some repositories may not want to allow a full clone, and\n+ * want users to first fetch from other repositories with\n+ * better connection.  By having a configuration variable like\n+ * this:\n+ *\n+ * [clonelimit \"v0.99\"]\n+ *   message = go to git://git.kernel.org/pub/scm/git/...\n+ *\n+ * a fetch request by a fetcher that does not have the named commit\n+ * is denied with the given message.\n+ */\n+struct clone_limit {\n+\tstruct clone_limit *next;\n+\tstruct commit *commit;\n+\tchar *ref; /* points at the tail of msg to store symbolic ref */\n+\tchar msg[FLEX_ARRAY]; /* message and more */\n+};\n+\n+static int check_clone_limit(const char *var, const char *value, void *cb_)\n+{\n+\tint msglen, reflen;\n+\tconst char *lastdot;\n+\tstruct clone_limit **clp = cb_;\n+\tstruct clone_limit *limit;\n+\tunsigned char sha1[20];\n+\n+\tif (prefixcmp(var, \"clonelimit.\"))\n+\t\treturn 0;\n+\n+\tif (debug_fd) {\n+\t\twrite_str_in_full(debug_fd, \"config: \");\n+\t\twrite_str_in_full(debug_fd, var);\n+\t\twrite_str_in_full(debug_fd, \" = <\");\n+\t\twrite_str_in_full(debug_fd, value);\n+\t\twrite_str_in_full(debug_fd, \">\\n\");\n+\t}\n+\n+\tvar += 11; /* skip \"clonelimit.\" */\n+\tlastdot = strrchr(var, '.');\n+\treflen = lastdot - var;\n+\tif (reflen < 0 || memcmp(var + reflen, \".message\", 9))\n+\t\treturn 0; /* not our variable */\n+\n+\t/*\n+\t * The remainder will ignore a malformed entry; we might\n+\t * want to abort the whole operation.  I dunno.\n+\t */\n+\tif (!value)\n+\t\treturn 0;\n+\tmsglen = strlen(value) + 1;\n+\tlimit = xmalloc(sizeof(*limit) + msglen + reflen + 1);\n+\tmemcpy(limit->msg, value, msglen);\n+\tlimit->ref = limit->msg + msglen;\n+\tmemcpy(limit->ref, var, reflen);\n+\tlimit->ref[reflen] = '\\0';\n+\tif (get_sha1(limit->ref, sha1)) {\n+\t\tfree(limit);\n+\t\treturn 0;\n+\t}\n+\tlimit->commit = lookup_commit_reference_gently(sha1, 0);\n+\tif (!limit->commit) {\n+\t\tfree(limit);\n+\t\treturn 0;\n+\t}\n+\tlimit->next = *clp;\n+\t*clp = limit;\n+\treturn 0;\n+}\n+\n+static int limit_served_history(void)\n+{\n+\tint has_missing, i, n;\n+\tstruct clone_limit *clone_limit = NULL;\n+\tstruct clone_limit *cl;\n+\tstruct commit **twos = NULL;\n+\tstruct commit_list *l;\n+\n+\tgit_config(check_clone_limit, &clone_limit);\n+\tif (!clone_limit)\n+\t\treturn 0;\n+\n+\ttwos = xcalloc(have_obj.nr, sizeof(*twos));\n+\tfor (i = n = 0; i < have_obj.nr; i++) {\n+\t\tstruct object *o = have_obj.objects[i].item;\n+\t\tstruct commit *have = lookup_commit_reference_gently(o->sha1, 0);\n+\t\tif (!have)\n+\t\t\tcontinue;\n+\t\ttwos[n++] = have;\n+\t}\n+\n+\thas_missing = 0;\n+\tfor (cl = clone_limit; cl; cl = cl->next) {\n+\t\tint seen = 0;\n+\t\tl = get_merge_bases_many(cl->commit, n, twos, 1);\n+\t\twhile (l) {\n+\t\t\tstruct commit_list *next = l->next;\n+\t\t\tif (!hashcmp(l->item->object.sha1, cl->commit->object.sha1))\n+\t\t\t\tseen = 1;\n+\t\t\tfree(l);\n+\t\t\tl = next;\n+\t\t}\n+\t\tif (!seen) {\n+\t\t\thas_missing = 1;\n+\t\t\terror(\"you do not have object '%s'; %s\",\n+\t\t\t      cl->ref, cl->msg);\n+\t\t}\n+\t}\n+\n+\twhile (clone_limit) {\n+\t\tstruct clone_limit *next = clone_limit->next;\n+\t\tfree(clone_limit);\n+\t\tclone_limit = next;\n+\t}\n+\tfree(twos);\n+\treturn has_missing;\n+}\n+\n static void upload_pack(void)\n {\n \tif (advertise_refs || !stateless_rpc) {\n@@ -672,6 +790,8 @@ static void upload_pack(void)\n \treceive_needs();\n \tif (want_obj.nr) {\n \t\tget_common_commits();\n+\t\tif (limit_served_history())\n+\t\t\tdie(\"git upload-pack: missing prerequisites\");\n \t\tcreate_pack_file();\n \t}\n }\n"}]}