git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Alex Levy <alex.levy@voltserver.com>
To: "git@vger.kernel.org" <git@vger.kernel.org>
Subject: possible submodule bug?
Date: Thu, 30 May 2019 18:16:17 +0000	[thread overview]
Message-ID: <BN8PR11MB35711F87B0981C6897DCE3CC89180@BN8PR11MB3571.namprd11.prod.outlook.com> (raw)

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



             reply	other threads:[~2019-05-30 18:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-30 18:16 Alex Levy [this message]
2019-06-01  1:12 ` possible submodule bug? brian m. carlson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=BN8PR11MB35711F87B0981C6897DCE3CC89180@BN8PR11MB3571.namprd11.prod.outlook.com \
    --to=alex.levy@voltserver.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

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

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 read-only IMAP folder(s) and NNTP newsgroup(s).