{"thread":{"id":"62575","subject":"[BUG] Changing remote URL of \"deinited\" submodule not taken into account","startedAt":"2024-11-30T07:49:25Z","lastAt":"2024-11-30T10:10:35Z","messageCount":3,"participants":["Nicolás Ojeda Bär","Kristoffer Haugsbakk"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"508371","messageId":"CAPunWhBQcAifapqxyq7nY+S5WWhZQhBKgeYLL56U1ewRCa7QDA@mail.gmail.com","threadId":"62575","inReplyTo":null,"subject":"[BUG] Changing remote URL of \"deinited\" submodule not taken into account","fromName":"Nicolás Ojeda Bär","fromEmail":"n.oje.bar@gmail.com","sentAt":"2024-11-30T07:48:59Z","receivedAt":"2024-11-30T07:49:25Z","isPatch":false,"sender":{"key":"n.oje.bar@gmail.com","avatar":null},"body":"Recently I came across an issue involving Git submodules which seems\nlike a bug to me.\n\nIn short (precise reproduction instructions below), if one updates the\nremote URL of a submodule while it is \"deinited\", the next time one\ncalls \"git update\" the old URL will be used instead of the new one.\n\nHere is how to reproduce the issue synthetically (in a fresh directory):\n\n  git init\n  git submodule add https://github.com/git/git-reference sub # random repo\n  git commit -m \"add submodule\"\n  git submodule deinit sub\n  git submodule init\n\nAt this point, the remote URL of the submodule has been copied to\n.git/config. We change it:\n\n  git config submodule.sub.url \"new-url\"\n\nNow we checkout the submodule. I am expecting to use \"new-url\" as\nremote URL in the checkout.\n\n  git submodule update sub\n\nHowever, the old URL is used:\n\n  git -C sub config remote.origin.url # => old URL instead of \"new-url\"\n\nThe problem seems to be that the clone at .git/modules/sub does not\nhave its remote URL updated when being \"inited\" after a remote URL\nchange while it was \"deinited\".\n\nCurrently I am working around this issue in scripts by doing:\n\n  if [ -f .git/modules/$sm_name/config ]\n  then\n    git config -f .git/modules/$sm_name/config remote.origin.url $(git\nconfig submodule.$sm_name.url)\n  fi\n\nAny insight would be appreciated. Thanks!\n\nCheers,\nNicolas\n"},{"id":"508373","messageId":"1e423f15-49e7-4f18-b6a7-612f1bdd7d5a@app.fastmail.com","threadId":"62575","inReplyTo":"CAPunWhBQcAifapqxyq7nY+S5WWhZQhBKgeYLL56U1ewRCa7QDA@mail.gmail.com","subject":"Re: [BUG] Changing remote URL of \"deinited\" submodule not taken into account","fromName":"Kristoffer Haugsbakk","fromEmail":"kristofferhaugsbakk@fastmail.com","sentAt":"2024-11-30T09:59:48Z","receivedAt":"2024-11-30T10:00:09Z","isPatch":false,"sender":{"key":"kristofferhaugsbakk@fastmail.com","avatar":null},"body":"Hi Nicolás\n\nOn Sat, Nov 30, 2024, at 08:48, Nicolás Ojeda Bär wrote:\n> Recently I came across an issue involving Git submodules which seems\n> like a bug to me.\n>\n> In short (precise reproduction instructions below), if one updates the\n> remote URL of a submodule while it is \"deinited\", the next time one\n> calls \"git update\" the old URL will be used instead of the new one.\n\nWhat’s your Git version? You can run `git bugreport` to let Git record a file\nabout your Git and system information. Then you can post it inline here.\n"},{"id":"508374","messageId":"CAPunWhDQZs=O-bGo7V07w==+4ptLpaEc7TWgFVNR1epq98BPRg@mail.gmail.com","threadId":"62575","inReplyTo":"1e423f15-49e7-4f18-b6a7-612f1bdd7d5a@app.fastmail.com","subject":"Re: [BUG] Changing remote URL of \"deinited\" submodule not taken into account","fromName":"Nicolás Ojeda Bär","fromEmail":"n.oje.bar@gmail.com","sentAt":"2024-11-30T10:10:09Z","receivedAt":"2024-11-30T10:10:35Z","isPatch":false,"sender":{"key":"n.oje.bar@gmail.com","avatar":null},"body":"On Sat, Nov 30, 2024 at 11:00 AM Kristoffer Haugsbakk\n<kristofferhaugsbakk@fastmail.com> wrote:\n>\n> What’s your Git version? You can run `git bugreport` to let Git record a file\n> about your Git and system information. Then you can post it inline here.\n\nHello, thanks for your reply. Below are two versions where I am able\nto reproduce the issue:\n\n[System Info]\ngit version:\ngit version 2.46.1\ncpu: x86_64\nno commit associated with this build\nsizeof-long: 8\nsizeof-size_t: 8\nshell-path: /bin/sh\nlibcurl: 7.68.0\nzlib: 1.2.11\nuname: Linux 5.15.167.4-microsoft-standard-WSL2 #1 SMP Tue Nov 5\n00:21:55 UTC 2024 x86_64\ncompiler info: gnuc: 9.4\nlibc info: glibc: 2.31\n$SHELL (typically, interactive shell): /bin/bash\n\n[System Info]\ngit version:\ngit version 2.47.0.windows.2\ncpu: x86_64\nbuilt from commit: 1f8a83cba6e88fad4b881885e64cfb89458e3653\nsizeof-long: 4\nsizeof-size_t: 8\nshell-path: D:/git-sdk-64-build-installers/usr/bin/sh\nfeature: fsmonitor--daemon\nlibcurl: 8.10.1\nOpenSSL: OpenSSL 3.2.3 3 Sep 2024\nzlib: 1.3.1\nuname: Windows 10.0 26100\ncompiler info: gnuc: 14.2\nlibc info: no libc information available\n$SHELL (typically, interactive shell): /bin/bash\n\nThanks!\n\nCheers,\nNicolas\n"}]}