{"thread":{"id":"24209","subject":"How does receive-pack and pre-receive hook works ?","startedAt":"2010-06-27T02:24:51Z","lastAt":"2010-06-27T07:00:51Z","messageCount":2,"participants":["Mahesh Vaidya","Shawn Pearce"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"144343","messageId":"AANLkTinYRF2m95MU2c817bK6mfehPt_OMBH45R6laNUe@mail.gmail.com","threadId":"24209","inReplyTo":null,"subject":"How does receive-pack and pre-receive hook works ?","fromName":"Mahesh Vaidya","fromEmail":"forvaidya@gmail.com","sentAt":"2010-06-27T02:24:51Z","receivedAt":"2010-06-27T02:24:51Z","isPatch":false,"sender":{"key":"forvaidya@gmail.com","avatar":null},"body":"How does receive-pack and pre-receive hook works ?\n\nI have added following in pre-recieve hook; all works fine. git\nrev-list --pretty d6d147f432869037a7ac8bdca3a2d5bc0cdc1e9f\n^a3fe19833480023b72350d6e56e939cbd0ba2c8b\n\nI Would like know where does Git saves whatever I am pushing before\nexit 0 of this hook; Specifically how does it understand about\n'd6d147f432869037a7ac8bdca3a2d5bc0cdc1e9f' which is not part of\ndestination depot / repo.\n\nThx/ Mahesh.\n"},{"id":"144346","messageId":"AANLkTikrSABpX8rFLIYwwQaN3zfnzEuqr6ugbPEOzo76@mail.gmail.com","threadId":"24209","inReplyTo":"AANLkTinYRF2m95MU2c817bK6mfehPt_OMBH45R6laNUe@mail.gmail.com","subject":"Re: How does receive-pack and pre-receive hook works ?","fromName":"Shawn Pearce","fromEmail":"spearce@spearce.org","sentAt":"2010-06-27T07:00:51Z","receivedAt":"2010-06-27T07:00:51Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"On Sat, Jun 26, 2010 at 7:24 PM, Mahesh Vaidya <forvaidya@gmail.com> wrote:\n> How does receive-pack and pre-receive hook works ?\n>\n> I Would like know where does Git saves whatever I am pushing before\n> exit 0 of this hook; Specifically how does it understand about\n> 'd6d147f432869037a7ac8bdca3a2d5bc0cdc1e9f' which is not part of\n> destination depot / repo.\n\nThe objects that were sent are actually added to the destination\nrepository, by creating one or more loose objects in the objects/\ndirectory, or a single new pack file in the objects/pack/ directory if\nmore than 100 objects were sent.  These objects are in the repository,\nbut they aren't actually reachable from any ref, so they are subject\nto garbage collection during a future `git gc`.  Once the objects are\nsafely stored, the hooks are invoked... which means the hooks can\naccess the objects, as they are already part of the repository.\n\nIf pre-receive or update exits with a non-zero status, the objects\nstay around, but the references aren't updated.  By not updating the\nreferences, the objects aren't reachable, and the objects will be\nautomatically removed during a future `git gc`.\n\n-- \nShawn.\n"}]}