{"thread":{"id":"51199","subject":"possible submodule bug?","startedAt":"2019-05-30T18:16:22Z","lastAt":"2019-06-01T01:12:16Z","messageCount":2,"participants":["Alex Levy","brian m. carlson"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"376447","messageId":"BN8PR11MB35711F87B0981C6897DCE3CC89180@BN8PR11MB3571.namprd11.prod.outlook.com","threadId":"51199","inReplyTo":null,"subject":"possible submodule bug?","fromName":"Alex Levy","fromEmail":"alex.levy@voltserver.com","sentAt":"2019-05-30T18:16:17Z","receivedAt":"2019-05-30T18:16:22Z","isPatch":false,"sender":{"key":"alex.levy@voltserver.com","avatar":null},"body":"Hi. I'm running git version 2.13.2.windows.1.  My coworker has the same behavior with 2.21.0.windows.1.\n\nI recently set up a git submodule by doing \"git submodule add https://github.com/VoltServer/example\".  Based on our teams preference, I then tried to update .gitmodules to use the alternate URL \"git@github.com:VoltServer/example.git\".  When I manually edited the .gitmodules file, I failed to type it in correctly, instead providing \"git@github.com/VoltServer/example\" (I think the same problem applies for any malformed URL).  After my coworker pulled this commit and tried to init the submodule we realized my mistake.  So, I fixed .gitmodules to use the correct URL, committed, and he pulled again.  Despite now having the correct URL, his superproject clone still failed to clone the submodule.  I found a workaround, but I'm not certain if the workaround was valid or not.\n\nHere are the recreation steps:\n\nmkdir example\ncd example\nmkdir a\ncd a\ngit init\ntouch foo\ngit add foo\ngit commit -m \"Initial commit.\"\ngit submodule add https://github.com/VoltServer/example\ngit commit -m \"Add submodule.\"\nvim .gitmodules // edit as described above\ngit add .gitmodules\ngit commit -m \"Update to wrong URL in .gitmodules.\"\ncd ..\ngit clone a b\ncd b\ngit submodule update --init\n\nThat last command gives the following output:\n\nSubmodule 'example' (git@github.com/VoltServer/example) registered for path 'example'\nfatal: repository 'git@github.com/VoltServer/example' does not exist\nfatal: clone of 'git@github.com/VoltServer/example' into submodule path 'C:/projects/temp/example/b/example' failed\nFailed to clone 'example'. Retry scheduled\nfatal: repository 'git@github.com/VoltServer/example' does not exist\nfatal: clone of 'git@github.com/VoltServer/example' into submodule path 'C:/projects/temp/example/b/example' failed\nFailed to clone 'example' a second time, aborting\n\nIf I now edit .gitmodules to reflect the correct URL:\n\ncd ../a\nvim .gitmodules // format the URL correctly\ngit add .gitmodules\ngit commit -m \"Fix .gitmodules URL.\"\ncd ../b\ngit pull\ngit submodule update --init\n\nThis gives the same error message as before, except with the first line about registering the submodule missing.\n\nI've found a workaround if I manually edit .git/config in each clone to reflect the correct URL.  After doing that, running \"git submodule update --init\" works as expected.\n\nMy understanding is that I shouldn't ever have to edit anything in the .git directory.  So, have I found a bug with .gitmodules being ignored after adding a given submodule?  Or is this just user error, a case of \"Don't do that.  Initialize the submodule with the correct URL and move on.\"?\n\nThanks,\nAlex\n\nAlex Levy\nFirmware Engineer\nVoltServer, Inc.\n42 Ladd Street, Suite 227\nEast Greenwich, RI 02818\nalex.levy@VoltServer.com\n888-622-8658 x413\n\n\n"},{"id":"376527","messageId":"20190601011206.GO8616@genre.crustytoothpaste.net","threadId":"51199","inReplyTo":"BN8PR11MB35711F87B0981C6897DCE3CC89180@BN8PR11MB3571.namprd11.prod.outlook.com","subject":"Re: possible submodule bug?","fromName":"brian m. carlson","fromEmail":"sandals@crustytoothpaste.net","sentAt":"2019-06-01T01:12:07Z","receivedAt":"2019-06-01T01:12:16Z","isPatch":false,"sender":{"key":"sandals@crustytoothpaste.net","avatar":"https://avatars.githubusercontent.com/u/497054?v=4"},"body":"On 2019-05-30 at 18:16:17, Alex Levy wrote:\n> I've found a workaround if I manually edit .git/config in each clone to reflect the correct URL.  After doing that, running \"git submodule update --init\" works as expected.\n> \n> My understanding is that I shouldn't ever have to edit anything in the .git directory.  So, have I found a bug with .gitmodules being ignored after adding a given submodule?  Or is this just user error, a case of \"Don't do that.  Initialize the submodule with the correct URL and move on.\"?\n\ngit-submodule(1) documents this behavior under the init subcommand:\n\n  When present, it will also copy the value of `submodule.$name.update`.\n  This command does not alter existing information in .git/config. You\n  can then customize the submodule clone URLs in .git/config for your\n  local setup and proceed to `git submodule update`; you can also just\n  use `git submodule update --init` without the explicit 'init' step if\n  you do not intend to customize any submodule locations.\n\nThe goal is to let you customize the URL. For example, maybe you are\nusing an open-source project with submodules but you're on a restricted\ncorporate network where access to certain sites is prohibited, or maybe\nthe server hosting the submodule is down temporarily or permanently.\n\nSo this isn't really a bug, but more of a feature, even if it's\ninconvenient in this particular case.\n\nYou can, however, use \"git submodule sync\" to sync across updated\nchanges to the URL. This is a bunch easier and faster than editing\nthings by hand or with \"git config\".\n-- \nbrian m. carlson: Houston, Texas, US\nOpenPGP: https://keybase.io/bk2204\n"}]}