git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [BUG] Changing remote URL of "deinited" submodule not taken into account
@ 2024-11-30  7:48 Nicolás Ojeda Bär
  2024-11-30  9:59 ` Kristoffer Haugsbakk
  0 siblings, 1 reply; 3+ messages in thread
From: Nicolás Ojeda Bär @ 2024-11-30  7:48 UTC (permalink / raw)
  To: git

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

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-11-30 10:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-30  7:48 [BUG] Changing remote URL of "deinited" submodule not taken into account Nicolás Ojeda Bär
2024-11-30  9:59 ` Kristoffer Haugsbakk
2024-11-30 10:10   ` Nicolás Ojeda Bär

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).