git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Intricacies of submodules

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 12, 2008, 05:25 UTC
Message-ID
<7vej9blk4j.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<46dff0320804112102t52a60072rc97c772a1e74f597@mail.gmail.com>
"Ping Yin" <pkufranky@gmail.com> writes:
Show 15 quoted lines
>>  After working with the project for a while (i.e. you pull and perhaps push
>>  back or send patches upstream), .gitmodules file changes and it now says
>>  the repository resides at host B.xz because the project relocated.  You
>>  would want the next "git submodule update" to notice that your .git/config
>>  records a URL you derived from git://A.xz/project.git/, and that you have
>>  not seen this new URL git://B.xz/project.git/, and give you a chance to
>>  make adjustments if needed.
>
> I think this should be done if "git submodule update" fails. The
> reason it fails may be different, such as newest commits not pushed
> out and the subproject relocated etc. So it can only given some hints
> with "maybe".
>
> However, how to detect the url has changed in .gitmodules? Compare the
> latest two version of .gitmodules?

That's why I suggested (and Roman seems to have got it, so I do not think what I wrote was too confusing to be understood) you should record the set of _all_ URLs you have _seen_ in .git/config. If the URL in .gitmodules checked out is included in that set, you do not do anything. Otherwise you ask.

I think "git submodule update" is a good place to do that check, but I'd prefer it be done _before_ it actually goes to the network to start accessing potentially stale URL. The old URL may not be defunct but the project decided not to advertise it to be used for some non-technical reason (e.g. the site owner asked them not to point at it and instead use some other mirrors).

> When bug happens, i only care the commit in the index of submodule and
> wheter i can check out the old submodule commit. However, does it
> really matter that what the url of the submodule is?

No. The discussion was what should _not_ happen when you run "git submodule update" from that state. Usually in a steadily advancing history, you _want_ "git submodule update" to notice that the suggested remote URL has changed in .gitmodules and give the user a chance to adjust the URL _before_ it hits the network, but you obviously do not want it to happen only because you happened to be at a seeked back commit when you initiated "git submodule update". In other words, you are agreeing with me without really reading what I wrote ;-) It does not matter, and recording the URLs you have _seen_ (not "the last one you saw", or "the one you initialized .git/config with") is a way to make sure that the fixed "git submodule update" agrees with us on that point.

Previous: Ping YinNext: Ping Yin
Message 42 of 48 in “Migrating svn to git with heavy use of externals”
  1. D. Stuart FreemanMar 31, 2008
  2. D. Stuart FreemanApr 8, 2008
  3. Avery PennarunApr 8, 2008
  4. D. Stuart FreemanApr 8, 2008
  5. Avery PennarunApr 8, 2008
  6. D. Stuart FreemanApr 8, 2008
  7. Roman ShaposhnikApr 9, 2008
  8. Avery PennarunApr 9, 2008
  9. Roman ShaposhnikApr 9, 2008
  10. Avery PennarunApr 9, 2008
  11. Junio C HamanoApr 9, 2008
  12. Intricacies of submodules [was: Migrating svn to git with heavy use of externals]Roman Shaposhnik, Apr 10, 2008
  13. Junio C HamanoApr 10, 2008
  14. Roman ShaposhnikApr 10, 2008
  15. Junio C HamanoApr 11, 2008
  16. Ping YinApr 11, 2008
  17. Junio C HamanoApr 11, 2008
  18. Roman ShaposhnikApr 12, 2008
  19. Junio C HamanoApr 12, 2008
  20. Roman ShaposhnikApr 14, 2008
  21. Junio C HamanoApr 15, 2008
  22. Ping YinApr 15, 2008
  23. Roman V. ShaposhnikApr 16, 2008
  24. Jeremy Maitin-ShepardApr 17, 2008
  25. Linus TorvaldsApr 17, 2008
  26. Junio C HamanoApr 17, 2008
  27. Roman V. ShaposhnikApr 17, 2008
  28. Martin LanghoffApr 17, 2008
  29. Junio C HamanoApr 17, 2008
  30. Sverre RabbelierApr 17, 2008
  31. Martin LanghoffApr 17, 2008
  32. Sverre RabbelierApr 17, 2008
  33. Martin LanghoffApr 17, 2008
  34. Ping YinApr 18, 2008
  35. Dmitry PotapovApr 17, 2008
  36. Linus TorvaldsApr 17, 2008
  37. Ping YinApr 18, 2008
  38. Jakub NarebskiApr 18, 2008
  39. Ping YinApr 12, 2008
  40. Roman ShaposhnikApr 14, 2008
  41. Ping YinApr 12, 2008
  42. Junio C HamanoApr 12, 2008
  43. Ping YinApr 12, 2008
  44. Ping YinApr 10, 2008
  45. Roman ShaposhnikApr 10, 2008
  46. Intricacies of submodules [was: Migrating svn to git with heavy use of externals]Roman Shaposhnik, Apr 9, 2008
  47. Avery PennarunApr 9, 2008
  48. Avery PennarunApr 18, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.