{"thread":{"id":"51794","subject":"Failure to fetch submodule with --depth=1 parameter","startedAt":"2019-09-03T15:30:15Z","lastAt":"2019-09-05T14:53:19Z","messageCount":3,"participants":["Grigory Yakushev","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"381728","messageId":"CACfeHrrajM8_p0=N8ZPm9h7ObcvWT5EnVa-gLhtDODdG9GeyBw@mail.gmail.com","threadId":"51794","inReplyTo":null,"subject":"Failure to fetch submodule with --depth=1 parameter","fromName":"Grigory Yakushev","fromEmail":"gy@daedalean.ai","sentAt":"2019-09-03T15:30:02Z","receivedAt":"2019-09-03T15:30:15Z","isPatch":false,"sender":{"key":"gy@daedalean.ai","avatar":null},"body":"$ git --version\ngit version 2.17.1\n\nRepro:\n$ git clone https://github.com/PX4/Firmware.git\n$ cd Firmware\n$ git submodule update --init --recursive --depth=1\n...\nerror: Server does not allow request for unadvertised object\n22df9475ca0d157e2db066a20f64c35906bf7f25\nFetched in submodule path 'Tools/sitl_gazebo', but it did not contain\n22df9475ca0d157e2db066a20f64c35906bf7f25. Direct fetching of that\ncommit failed.\n\nThe same line without --depth=1 flag works fine:\n$ git submodule update --init --recursive\n\nImplication:\nDocker uses the line with --depth=1, so it fails to build from remote\nURLs. See https://github.com/docker/distribution/issues/2998\n"},{"id":"381788","messageId":"20190904031426.GC28836@sigill.intra.peff.net","threadId":"51794","inReplyTo":"CACfeHrrajM8_p0=N8ZPm9h7ObcvWT5EnVa-gLhtDODdG9GeyBw@mail.gmail.com","subject":"Re: Failure to fetch submodule with --depth=1 parameter","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2019-09-04T03:14:26Z","receivedAt":"2019-09-04T03:14:28Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Sep 03, 2019 at 05:30:02PM +0200, Grigory Yakushev wrote:\n\n> $ git --version\n> git version 2.17.1\n> \n> Repro:\n> $ git clone https://github.com/PX4/Firmware.git\n> $ cd Firmware\n> $ git submodule update --init --recursive --depth=1\n> ...\n> error: Server does not allow request for unadvertised object\n> 22df9475ca0d157e2db066a20f64c35906bf7f25\n> Fetched in submodule path 'Tools/sitl_gazebo', but it did not contain\n> 22df9475ca0d157e2db066a20f64c35906bf7f25. Direct fetching of that\n> commit failed.\n> \n> The same line without --depth=1 flag works fine:\n> $ git submodule update --init --recursive\n\nI think what's happening is this: the super-project (PX4/Firmware)\npoints to a specific sha1 in the submodule (Tools/sitl_gazebo). But\nthere's no branch pointing at that sha1, so the client cannot ask for it\ndirectly.\n\nAs a fallback we instead fetch HEAD from the submodule and hope that we\ngot the sha1 we needed. But because we pass along \"--depth=1\", that\nfallback is not likely to work.\n\nIMHO one obvious improvement on the client side is to have a third-level\nfallback to do a full clone, and hope we get it then.\n\nHowever, there may a be an easier solution. In the v2 protocol, Git does\nnot enforce any advertisement or reachability properties for items the\nclient asks for. So the client would be free to just ask for the sha1\ndirectly, no fallback required.\n\nTry setting:\n\n  git config --global protocol.version 2\n\nwhich seems to make it work.\n\n-Peff\n"},{"id":"381866","messageId":"CACfeHrpfSJ8fEwqr66snRnc3pEk_jTrYHCRLtKFgaL9p4ZKthQ@mail.gmail.com","threadId":"51794","inReplyTo":"20190904031426.GC28836@sigill.intra.peff.net","subject":"Re: Failure to fetch submodule with --depth=1 parameter","fromName":"Grigory Yakushev","fromEmail":"gy@daedalean.ai","sentAt":"2019-09-05T14:53:06Z","receivedAt":"2019-09-05T14:53:19Z","isPatch":false,"sender":{"key":"gy@daedalean.ai","avatar":null},"body":"Thanks Jeff!\n\nCompletely solved the problem for me.\n\nOn Wed, Sep 4, 2019 at 5:14 AM Jeff King <peff@peff.net> wrote:\n>\n> On Tue, Sep 03, 2019 at 05:30:02PM +0200, Grigory Yakushev wrote:\n>\n> > $ git --version\n> > git version 2.17.1\n> >\n> > Repro:\n> > $ git clone https://github.com/PX4/Firmware.git\n> > $ cd Firmware\n> > $ git submodule update --init --recursive --depth=1\n> > ...\n> > error: Server does not allow request for unadvertised object\n> > 22df9475ca0d157e2db066a20f64c35906bf7f25\n> > Fetched in submodule path 'Tools/sitl_gazebo', but it did not contain\n> > 22df9475ca0d157e2db066a20f64c35906bf7f25. Direct fetching of that\n> > commit failed.\n> >\n> > The same line without --depth=1 flag works fine:\n> > $ git submodule update --init --recursive\n>\n> I think what's happening is this: the super-project (PX4/Firmware)\n> points to a specific sha1 in the submodule (Tools/sitl_gazebo). But\n> there's no branch pointing at that sha1, so the client cannot ask for it\n> directly.\n>\n> As a fallback we instead fetch HEAD from the submodule and hope that we\n> got the sha1 we needed. But because we pass along \"--depth=1\", that\n> fallback is not likely to work.\n>\n> IMHO one obvious improvement on the client side is to have a third-level\n> fallback to do a full clone, and hope we get it then.\n>\n> However, there may a be an easier solution. In the v2 protocol, Git does\n> not enforce any advertisement or reachability properties for items the\n> client asks for. So the client would be free to just ask for the sha1\n> directly, no fallback required.\n>\n> Try setting:\n>\n>   git config --global protocol.version 2\n>\n> which seems to make it work.\n>\n> -Peff\n"}]}