{"thread":{"id":"30328","subject":"Is there a way to fetch commits that are detached","startedAt":"2012-04-24T21:49:28Z","lastAt":"2012-04-24T22:15:48Z","messageCount":2,"participants":["Allan Caffee","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"189998","messageId":"CA+jCPNcmcxQcSN_BNvigQa2uRiaw-c2PK5T-y1yacYNs6Ws4WA@mail.gmail.com","threadId":"30328","inReplyTo":null,"subject":"Is there a way to fetch commits that are detached","fromName":"Allan Caffee","fromEmail":"allan.caffee@gmail.com","sentAt":"2012-04-24T21:49:28Z","receivedAt":"2012-04-24T21:49:28Z","isPatch":false,"sender":{"key":"allan.caffee@gmail.com","avatar":"https://avatars.githubusercontent.com/u/114759?v=4"},"body":"First some context: I'm trying to use the pre-receive hook to run some tests\non a Hudson server before accepting the updates to a branch. At the moment I'm\ntrying to have the Hudson job clone the repository (using the \"git\" protocol)\nand checkout the new ref as a detached head e.g.\n\n$ git clone $GIT_REPOSITORY repository\n$ cd repository\n$ git checkout $GIT_COMMIT\n\nBut the checkout fails, apparently because the commit object hasn't been\npulled into the local repository. Only a pack file is present in the local\nrepository's objects directory which presumably doesn't have the commit.\n\nIs there a way to explicitly fetch whatever objects are necessary to checkout\nthe commit?\n\nWould I be better off using git-archive to tar up a copy of the source\ninstead, or some other means of copying the codebase over for testing?\n\nThanks,\nAllan\n"},{"id":"190001","messageId":"xmqq62cog4iz.fsf@junio.mtv.corp.google.com","threadId":"30328","inReplyTo":"CA+jCPNcmcxQcSN_BNvigQa2uRiaw-c2PK5T-y1yacYNs6Ws4WA@mail.gmail.com","subject":"Re: Is there a way to fetch commits that are detached","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-04-24T22:15:48Z","receivedAt":"2012-04-24T22:15:48Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Allan Caffee <allan.caffee@gmail.com> writes:\n\n> Is there a way to explicitly fetch whatever objects are necessary to checkout\n> the commit?\n\nOne security principle built into git is that any object that is\nunreachable from refs/* is not to be exposed to outside world.  If the\ncommit is not on any ref, you shouldn't be able to obtain it remotely.\n\nSo you need to know which branch (or it could be a tag) the commit you\nwant is on, fetch that branch or tag and then check the commit out.\n"}]}