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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux