{"thread":{"id":"62482","subject":"Shallow clone of a specific git revision?","startedAt":"2024-11-12T12:24:59Z","lastAt":"2024-11-15T10:43:31Z","messageCount":6,"participants":["Michal Suchánek","Toon Claes","David Aguilar","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"507136","messageId":"ZzNJGHMlxGQyFV_c@kitsune.suse.cz","threadId":"62482","inReplyTo":null,"subject":"Shallow clone of a specific git revision?","fromName":"Michal Suchánek","fromEmail":"msuchanek@suse.de","sentAt":"2024-11-12T12:24:56Z","receivedAt":"2024-11-12T12:24:59Z","isPatch":false,"sender":{"key":"msuchanek@suse.de","avatar":"https://avatars.githubusercontent.com/u/787652?v=4"},"body":"Hello,\n\nLooking through clone man page it supports shallow clones of branches\nand tags only.\n\nWould it be possible to do shallow clone of a specific revision,\nand checkout specific revision on clone?\n\nThanks\n\nMichal\n\n"},{"id":"507203","messageId":"87wmh7ig98.fsf@iotcl.com","threadId":"62482","inReplyTo":"ZzNJGHMlxGQyFV_c@kitsune.suse.cz","subject":"Re: Shallow clone of a specific git revision?","fromName":"Toon Claes","fromEmail":"toon@iotcl.com","sentAt":"2024-11-13T10:23:47Z","receivedAt":"2024-11-13T10:24:02Z","isPatch":false,"sender":{"key":"toon@iotcl.com","avatar":"https://avatars.githubusercontent.com/u/121621?v=4"},"body":"Michal Suchánek <msuchanek@suse.de> writes:\n\n> Hello,\n>\n> Looking through clone man page it supports shallow clones of branches\n> and tags only.\n>\n> Would it be possible to do shallow clone of a specific revision,\n> and checkout specific revision on clone?\n\nHi Michal,\n\nI'm working on a patch, and I've submitted a first version [1] a little\nwhile ago to allow users to pass a reference on git-clone(1). Would this\nchange fit your needs, or what else would you like to support?\n\n--\nToon\n\n\n\n[1]: https://lore.kernel.org/git/20240927085438.1010431-1-toon@iotcl.com/\n"},{"id":"507204","messageId":"ZzR_nOqQxfGNPyYV@kitsune.suse.cz","threadId":"62482","inReplyTo":"87wmh7ig98.fsf@iotcl.com","subject":"Re: Shallow clone of a specific git revision?","fromName":"Michal Suchánek","fromEmail":"msuchanek@suse.de","sentAt":"2024-11-13T10:29:48Z","receivedAt":"2024-11-13T10:29:50Z","isPatch":false,"sender":{"key":"msuchanek@suse.de","avatar":"https://avatars.githubusercontent.com/u/787652?v=4"},"body":"On Wed, Nov 13, 2024 at 11:23:47AM +0100, Toon Claes wrote:\n> Michal Suchánek <msuchanek@suse.de> writes:\n> \n> > Hello,\n> >\n> > Looking through clone man page it supports shallow clones of branches\n> > and tags only.\n> >\n> > Would it be possible to do shallow clone of a specific revision,\n> > and checkout specific revision on clone?\n> \n> Hi Michal,\n> \n> I'm working on a patch, and I've submitted a first version [1] a little\n> while ago to allow users to pass a reference on git-clone(1). Would this\n> change fit your needs, or what else would you like to support?\n\n> [1]: https://lore.kernel.org/git/20240927085438.1010431-1-toon@iotcl.com/\n\nHello,\n\nthat slightly expands the available options but it does not make it\npossible to clone an arbitrary revision, ie. specified by a SHA\n\nThanks\n\nMichal\n"},{"id":"507313","messageId":"ZzbVe79p_Zbnb6rs@gmail.com","threadId":"62482","inReplyTo":"ZzR_nOqQxfGNPyYV@kitsune.suse.cz","subject":"Re: Shallow clone of a specific git revision?","fromName":"David Aguilar","fromEmail":"davvid@gmail.com","sentAt":"2024-11-15T05:00:43Z","receivedAt":"2024-11-15T05:00:47Z","isPatch":false,"sender":{"key":"davvid@gmail.com","avatar":"https://avatars.githubusercontent.com/u/13196?v=4"},"body":"On Wed, Nov 13, 2024 at 11:29:48AM +0100, Michal Suchánek wrote:\n> On Wed, Nov 13, 2024 at 11:23:47AM +0100, Toon Claes wrote:\n> > Michal Suchánek <msuchanek@suse.de> writes:\n> > \n> > > Hello,\n> > >\n> > > Looking through clone man page it supports shallow clones of branches\n> > > and tags only.\n> > >\n> > > Would it be possible to do shallow clone of a specific revision,\n> > > and checkout specific revision on clone?\n> > \n> > Hi Michal,\n> > \n> > I'm working on a patch, and I've submitted a first version [1] a little\n> > while ago to allow users to pass a reference on git-clone(1). Would this\n> > change fit your needs, or what else would you like to support?\n> \n> > [1]: https://lore.kernel.org/git/20240927085438.1010431-1-toon@iotcl.com/\n> \n> Hello,\n> \n> that slightly expands the available options but it does not make it\n> possible to clone an arbitrary revision, ie. specified by a SHA\n> \n> Thanks\n> \n> Michal\n\nIn case it helps, here's a short recipe demonstrating how to do a\nshallow \"clone\" of a specific commit ID:\n\n    git init the-repo\n    cd ./the-repo\n    git remote add origin <url>\n    git fetch --depth=1 origin <commit-id>\n    git checkout <commit-id>\n\nIt'd be nice to add this feature to \"git clone\" for convenience.\n\nThis recipe depends on the server's configuration. You must have one of\nthe following configuration variables set \"true\" server-side in order\nfor the server to accept requests for arbitrary commit IDs:\n\n    uploadpack.allowReachableSHA1InWant\n        Allow upload-pack to accept a fetch request that asks for an\n        object that is reachable from any ref tip. However, note that\n        calculating object reachability is computationally expensive.\n        Defaults to false. Even if this is false, a client may be able\n        to steal objects via the techniques described in the \"SECURITY\"\n        section of the gitnamespaces(7) man page; it’s best to keep\n        private data in a separate repository.\n\n    uploadpack.allowAnySHA1InWant\n        Allow upload-pack to accept a fetch request that asks for any\n        object at all. Defaults to false.\n\ncheers,\n-- \nDavid\n"},{"id":"507351","messageId":"20241115093749.GB1749331@coredump.intra.peff.net","threadId":"62482","inReplyTo":"ZzbVe79p_Zbnb6rs@gmail.com","subject":"Re: Shallow clone of a specific git revision?","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2024-11-15T09:37:49Z","receivedAt":"2024-11-15T09:37:50Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Nov 14, 2024 at 09:00:43PM -0800, David Aguilar wrote:\n\n> In case it helps, here's a short recipe demonstrating how to do a\n> shallow \"clone\" of a specific commit ID:\n> \n>     git init the-repo\n>     cd ./the-repo\n>     git remote add origin <url>\n>     git fetch --depth=1 origin <commit-id>\n>     git checkout <commit-id>\n> \n> It'd be nice to add this feature to \"git clone\" for convenience.\n\nAgreed on all parts of this, but wanted to mention one thing here:\n\n> This recipe depends on the server's configuration. You must have one of\n> the following configuration variables set \"true\" server-side in order\n> for the server to accept requests for arbitrary commit IDs:\n> \n>     uploadpack.allowReachableSHA1InWant\n>         Allow upload-pack to accept a fetch request that asks for an\n>         object that is reachable from any ref tip. However, note that\n>         calculating object reachability is computationally expensive.\n>         Defaults to false. Even if this is false, a client may be able\n>         to steal objects via the techniques described in the \"SECURITY\"\n>         section of the gitnamespaces(7) man page; it’s best to keep\n>         private data in a separate repository.\n> \n>     uploadpack.allowAnySHA1InWant\n>         Allow upload-pack to accept a fetch request that asks for any\n>         object at all. Defaults to false.\n\nIn the v2 protocol, the reachability checks are gone (as if allowAny was\nset). So if the server speaks v2, your instructions should just work.\nMost servers should be new enough to support this (and certainly big\nforges like GitHub and GitLab do), though note that for git-over-ssh the\nserver side might need to configure ssh to allow the correct environment\nvariables. There's discussion in the GIT_PROTOCOL section of git(1).\n\n-Peff\n"},{"id":"507355","messageId":"Zzcl0Ql0S386G4FO@kitsune.suse.cz","threadId":"62482","inReplyTo":"ZzbVe79p_Zbnb6rs@gmail.com","subject":"Re: Shallow clone of a specific git revision?","fromName":"Michal Suchánek","fromEmail":"msuchanek@suse.de","sentAt":"2024-11-15T10:43:29Z","receivedAt":"2024-11-15T10:43:31Z","isPatch":false,"sender":{"key":"msuchanek@suse.de","avatar":"https://avatars.githubusercontent.com/u/787652?v=4"},"body":"Hello,\n\nOn Thu, Nov 14, 2024 at 09:00:43PM -0800, David Aguilar wrote:\n> On Wed, Nov 13, 2024 at 11:29:48AM +0100, Michal Suchánek wrote:\n> > On Wed, Nov 13, 2024 at 11:23:47AM +0100, Toon Claes wrote:\n> > > Michal Suchánek <msuchanek@suse.de> writes:\n> > > \n> > > > Hello,\n> > > >\n> > > > Looking through clone man page it supports shallow clones of branches\n> > > > and tags only.\n> > > >\n> > > > Would it be possible to do shallow clone of a specific revision,\n> > > > and checkout specific revision on clone?\n> > > \n> > > Hi Michal,\n> > > \n> > > I'm working on a patch, and I've submitted a first version [1] a little\n> > > while ago to allow users to pass a reference on git-clone(1). Would this\n> > > change fit your needs, or what else would you like to support?\n> > \n> > > [1]: https://lore.kernel.org/git/20240927085438.1010431-1-toon@iotcl.com/\n> > \n> > Hello,\n> > \n> > that slightly expands the available options but it does not make it\n> > possible to clone an arbitrary revision, ie. specified by a SHA\n> > \n> > Thanks\n> > \n> > Michal\n> \n> In case it helps, here's a short recipe demonstrating how to do a\n\nYes, that's helpful, thanks.\n\n> shallow \"clone\" of a specific commit ID:\n> \n>     git init the-repo\n>     cd ./the-repo\n>     git remote add origin <url>\n>     git fetch --depth=1 origin <commit-id>\n>     git checkout <commit-id>\n> \n> It'd be nice to add this feature to \"git clone\" for convenience.\n\nThis is how many git reatures start, after all. They are provided as a\nscript on top of core git functionality.\n\n> This recipe depends on the server's configuration. You must have one of\n> the following configuration variables set \"true\" server-side in order\n> for the server to accept requests for arbitrary commit IDs:\n> \n>     uploadpack.allowReachableSHA1InWant\n>         Allow upload-pack to accept a fetch request that asks for an\n>         object that is reachable from any ref tip. However, note that\n>         calculating object reachability is computationally expensive.\n>         Defaults to false. Even if this is false, a client may be able\n>         to steal objects via the techniques described in the \"SECURITY\"\n>         section of the gitnamespaces(7) man page; it’s best to keep\n>         private data in a separate repository.\n> \n>     uploadpack.allowAnySHA1InWant\n>         Allow upload-pack to accept a fetch request that asks for any\n>         object at all. Defaults to false.\n\nI would be fetching from a forge most of the time which would use its own\nimplementation of git server most of the time but it's good to know what\nthe options are on the canonical implementation at least.\n\nThanks\n\nMichal\n"}]}