git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Possible bug: Git submodules can get into broken state
@ 2013-04-04 17:10 Chris Wilson
  2013-04-04 18:30 ` Junio C Hamano
  2013-04-04 19:56 ` Jens Lehmann
  0 siblings, 2 replies; 7+ messages in thread
From: Chris Wilson @ 2013-04-04 17:10 UTC (permalink / raw)
  To: git

Hi all,

If your git repo's .gitmodules contains a URL that you don't have access 
to (for example you download someone else's code and it references a 
submodule using their writable git@github.com URL) then:

* git submodule init will add them to .git/config, with the wrong URLs.

* git submodule update will fail to check out the repos, leaving an empty 
directory for the first one, and nothing for the others.

This state is broken (wrong URLs in .git/config), and AFAIK there's 
nothing you can do to check out these submodules without either:

(a) manually hacking them out of .git/config, or

(b) doing "git submodule rm" and then "git checkout .gitmodules" to undo 
the damage to that file.

The procedure I tried, which I expected to work, was:

* git submodule sync (doesn't sync them, because the directories don't 
exist or don't contain a valid git repo?)

* git submodule init (ignores them, because they're already in 
.git/config?)

* git submodule update (still fails because the URL in .git/config is 
wrong).

The new deinit command may help, but for the wrong reasons. I don't want 
to have to deinit my modules every time in the fabric deployment script, 
just so that if they get into this state, they will get unbroken 
automatically.

It seems wrong to me that neither "git submodule init" nor "git submodule 
sync" will modify the URL in .git/config, if the submodule is not already 
checked out. I think I'd expect "git submodule init" to be idempotent, so 
it would update the URLs in .git/config if they already exist, just like 
it adds the URLs if they don't.

Any advice? Is this a real bug?

Cheers, Chris.
-- 
Aptivate | http://www.aptivate.org | Phone: +44 1223 967 838
Future Business, Cam City FC, Milton Rd, Cambridge, CB4 1UY, UK

Aptivate is a not-for-profit company registered in England and Wales
with company number 04980791.

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

end of thread, other threads:[~2013-04-06 16:51 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-04-04 17:10 Possible bug: Git submodules can get into broken state Chris Wilson
2013-04-04 18:30 ` Junio C Hamano
2013-04-04 20:40   ` Chris Wilson
2013-04-04 21:07     ` Junio C Hamano
2013-04-04 22:07       ` Chris Wilson
2013-04-05 16:51         ` Junio C Hamano
2013-04-04 19:56 ` Jens Lehmann

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