threads / bug / 62575

[BUG] Changing remote URL of "deinited" submodule not taken into account

Subject: [BUG] Changing remote URL of "deinited" submodule not taken into account

## tl;dr

3 messages between Nov 30, 2024 and Nov 30, 2024.

replies: 2people: 2as markdown or json

Nicolás Ojeda Bär· Nov 30, 2024, 07:48 UTC · lore

Recently I came across an issue involving Git submodules which seems like a bug to me.

In short (precise reproduction instructions below), if one updates the remote URL of a submodule while it is "deinited", the next time one calls "git update" the old URL will be used instead of the new one.

Here is how to reproduce the issue synthetically (in a fresh directory):
  git init
  git submodule add https://github.com/git/git-reference sub # random repo
  git commit -m "add submodule"
  git submodule deinit sub
  git submodule init

At this point, the remote URL of the submodule has been copied to .git/config. We change it:

  git config submodule.sub.url "new-url"

Now we checkout the submodule. I am expecting to use "new-url" as remote URL in the checkout.

  git submodule update sub
However, the old URL is used:
  git -C sub config remote.origin.url # => old URL instead of "new-url"

The problem seems to be that the clone at .git/modules/sub does not have its remote URL updated when being "inited" after a remote URL change while it was "deinited".

Currently I am working around this issue in scripts by doing:
  if [ -f .git/modules/$sm_name/config ]
  then
    git config -f .git/modules/$sm_name/config remote.origin.url $(git
config submodule.$sm_name.url)
  fi
Any insight would be appreciated. Thanks!

Cheers, Nicolas

Kristoffer Haugsbakk· Nov 30, 2024, 09:59 UTC · re: Nicolás Ojeda Bär · lore

Re: [BUG] Changing remote URL of "deinited" submodule not taken into account

Hi Nicolás
On Sat, Nov 30, 2024, at 08:48, Nicolás Ojeda Bär wrote:
Show 6 quoted lines
> Recently I came across an issue involving Git submodules which seems
> like a bug to me.
>
> In short (precise reproduction instructions below), if one updates the
> remote URL of a submodule while it is "deinited", the next time one
> calls "git update" the old URL will be used instead of the new one.

What’s your Git version? You can run `git bugreport` to let Git record a file about your Git and system information. Then you can post it inline here.

Nicolás Ojeda Bär· Nov 30, 2024, 10:10 UTC · re: Kristoffer Haugsbakk · lore

Re: [BUG] Changing remote URL of "deinited" submodule not taken into account

On Sat, Nov 30, 2024 at 11:00 AM Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com> wrote:

>
> What’s your Git version? You can run `git bugreport` to let Git record a file
> about your Git and system information. Then you can post it inline here.

Hello, thanks for your reply. Below are two versions where I am able to reproduce the issue:

[System Info] git version: git version 2.46.1 cpu: x86_64 no commit associated with this build sizeof-long: 8 sizeof-size_t: 8 shell-path: /bin/sh libcurl: 7.68.0 zlib: 1.2.11 uname: Linux 5.15.167.4-microsoft-standard-WSL2 #1 SMP Tue Nov 5 00:21:55 UTC 2024 x86_64 compiler info: gnuc: 9.4 libc info: glibc: 2.31 $SHELL (typically, interactive shell): /bin/bash

[System Info]
git version:
git version 2.47.0.windows.2
cpu: x86_64
built from commit: 1f8a83cba6e88fad4b881885e64cfb89458e3653
sizeof-long: 4
sizeof-size_t: 8
shell-path: D:/git-sdk-64-build-installers/usr/bin/sh
feature: fsmonitor--daemon
libcurl: 8.10.1
OpenSSL: OpenSSL 3.2.3 3 Sep 2024
zlib: 1.3.1
uname: Windows 10.0 26100
compiler info: gnuc: 14.2
libc info: no libc information available
$SHELL (typically, interactive shell): /bin/bash
Thanks!

Cheers, Nicolas

← back to recent threads