git@vger.kernel.org list mirror (unofficial, one of many)
 help / color / mirror / Atom feed
* possible submodule bug?
@ 2019-05-30 18:16 Alex Levy
  2019-06-01  1:12 ` brian m. carlson
  0 siblings, 1 reply; 2+ messages in thread
From: Alex Levy @ 2019-05-30 18:16 UTC (permalink / raw)
  To: git

Hi. I'm running git version 2.13.2.windows.1.  My coworker has the same behavior with 2.21.0.windows.1.

I 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.

Here are the recreation steps:

mkdir example
cd example
mkdir a
cd a
git init
touch foo
git add foo
git commit -m "Initial commit."
git submodule add https://github.com/VoltServer/example
git commit -m "Add submodule."
vim .gitmodules // edit as described above
git add .gitmodules
git commit -m "Update to wrong URL in .gitmodules."
cd ..
git clone a b
cd b
git submodule update --init

That last command gives the following output:

Submodule 'example' (git@github.com/VoltServer/example) registered for path 'example'
fatal: repository 'git@github.com/VoltServer/example' does not exist
fatal: clone of 'git@github.com/VoltServer/example' into submodule path 'C:/projects/temp/example/b/example' failed
Failed to clone 'example'. Retry scheduled
fatal: repository 'git@github.com/VoltServer/example' does not exist
fatal: clone of 'git@github.com/VoltServer/example' into submodule path 'C:/projects/temp/example/b/example' failed
Failed to clone 'example' a second time, aborting

If I now edit .gitmodules to reflect the correct URL:

cd ../a
vim .gitmodules // format the URL correctly
git add .gitmodules
git commit -m "Fix .gitmodules URL."
cd ../b
git pull
git submodule update --init

This gives the same error message as before, except with the first line about registering the submodule missing.

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.

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."?

Thanks,
Alex

Alex Levy
Firmware Engineer
VoltServer, Inc.
42 Ladd Street, Suite 227
East Greenwich, RI 02818
alex.levy@VoltServer.com
888-622-8658 x413



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

* Re: possible submodule bug?
  2019-05-30 18:16 possible submodule bug? Alex Levy
@ 2019-06-01  1:12 ` brian m. carlson
  0 siblings, 0 replies; 2+ messages in thread
From: brian m. carlson @ 2019-06-01  1:12 UTC (permalink / raw)
  To: Alex Levy; +Cc: git

[-- Attachment #1: Type: text/plain, Size: 1661 bytes --]

On 2019-05-30 at 18:16:17, Alex Levy wrote:
> 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.
> 
> 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."?

git-submodule(1) documents this behavior under the init subcommand:

  When present, it will also copy the value of `submodule.$name.update`.
  This command does not alter existing information in .git/config. You
  can then customize the submodule clone URLs in .git/config for your
  local setup and proceed to `git submodule update`; you can also just
  use `git submodule update --init` without the explicit 'init' step if
  you do not intend to customize any submodule locations.

The goal is to let you customize the URL. For example, maybe you are
using an open-source project with submodules but you're on a restricted
corporate network where access to certain sites is prohibited, or maybe
the server hosting the submodule is down temporarily or permanently.

So this isn't really a bug, but more of a feature, even if it's
inconvenient in this particular case.

You can, however, use "git submodule sync" to sync across updated
changes to the URL. This is a bunch easier and faster than editing
things by hand or with "git config".
-- 
brian m. carlson: Houston, Texas, US
OpenPGP: https://keybase.io/bk2204

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 868 bytes --]

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

end of thread, other threads:[~2019-06-01  1:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-30 18:16 possible submodule bug? Alex Levy
2019-06-01  1:12 ` brian m. carlson

git@vger.kernel.org list mirror (unofficial, one of many)

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://public-inbox.org/git
	git clone --mirror http://ou63pmih66umazou.onion/git
	git clone --mirror http://czquwvybam4bgbro.onion/git
	git clone --mirror http://hjrcffqmbrq6wope.onion/git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 git git/ https://public-inbox.org/git \
		git@vger.kernel.org
	public-inbox-index git

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.public-inbox.org/inbox.comp.version-control.git
	nntp://ou63pmih66umazou.onion/inbox.comp.version-control.git
	nntp://czquwvybam4bgbro.onion/inbox.comp.version-control.git
	nntp://hjrcffqmbrq6wope.onion/inbox.comp.version-control.git
	nntp://news.gmane.io/gmane.comp.version-control.git
 note: .onion URLs require Tor: https://www.torproject.org/

code repositories for the project(s) associated with this inbox:

	https://80x24.org/mirrors/git.git

AGPL code for this site: git clone https://public-inbox.org/public-inbox.git