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

Re: question about git-submodule

From
ETEran Tromer <git2eran@tromer.org>
Date
Aug 3, 2007, 23:01 UTC
Message-ID
<46B3B3D2.6030000@tromer.org>
In-Reply-To
<20070715104712.GF2568@steel.home>
On 2007-07-15 06:47, Alex Riesen wrote:
Show 17 quoted lines
> Sven Verdoolaege, Sun, Jul 15, 2007 10:39:59 +0200:
>> On Fri, Jul 13, 2007 at 11:46:30PM +0200, VMiklos wrote:
>>> i mean, first i thought that after configuring a submodule under libfoo,
>>> then a git pull will update libfoo's repo under libfoo, too. or
>>> something like that.
>> Unless I've missed something, it doesn't.
>> Some of use would like git to do just that (at least Alex Riesen,
>> Martin Waitz and myself have sent in patches to that effect),
>> but we haven't been able to convince Junio yet.
> 
> Count me out. Junio convinced me instead and having tried the
> subprojects I find it really convenient: I can choose when and what
> should be updated and I can see what _can_ be updated, iff I decide
> to. Subprojects defined in such a loosely way are more flexible then
> having git-pull fetch subprojects by default. Sometimes I even want be
> _sure_ the subprojects are completely untouched (I have some critical
> parts in them).

All of the above also applies to normal files, not just submodules. So by this logic, maybe "git pull" and "git checkout" should by default update just the index, and require a manual "git file update" to update the files in the working tree?

Leaving the working tree (including submodules) in an inconsistent state right after a pull or checkout is a very strange thing to do. It means, for example, that even simple switching between branches doesn't work in a superproject. Consider this example (tested on next aac97aacbccd):

-------------------------------------------------- Create the subproject repo:

$ mkdir sub-to-be $ cd sub-to-be $ git init $ echo AAA > foo $ git add foo $ git commit -m sub $ cd ..

Create the superproject repo and clone subproject into it:

$ mkdir super $ cd super $ git init $ git submodule add ../sub-to-be sub $ git commit -m super

Update the submodule:

$ cd sub $ echo BBB > foo $ git add foo $ git commit -m sub $ cd ..

Update the supermodule:

$ git add sub $ git commit -m super

Try to switch between versions, and fail miserably:

$ git checkout -b old HEAD^ M sub Switched to a new branch "old" $ git checkout master fatal: Entry 'sub' not uptodate. Cannot merge. --------------------------------------------------

BTW, is there any easy way to create a submodule directly inside the supermodule's working tree, instead of cloning it as in the above example?

  Eran
Previous: Sven VerdoolaegeNext: Sven Verdoolaege
Message 20 of 22 in “question about git-submodule”
  1. VMiklosJul 13, 2007
  2. Sven VerdoolaegeJul 15, 2007
  3. Alex RiesenJul 15, 2007
  4. VMiklosJul 15, 2007
  5. Alex RiesenJul 15, 2007
  6. VMiklosJul 15, 2007
  7. Sven VerdoolaegeJul 15, 2007
  8. VMiklosJul 15, 2007
  9. Sven VerdoolaegeJul 15, 2007
  10. VMiklosJul 15, 2007
  11. Sven VerdoolaegeJul 15, 2007
  12. VMiklosJul 15, 2007
  13. Sven VerdoolaegeJul 15, 2007
  14. VMiklosJul 15, 2007
  15. Sven VerdoolaegeJul 16, 2007
  16. VMiklosJul 16, 2007
  17. Sven VerdoolaegeJul 15, 2007
  18. Alex RiesenJul 15, 2007
  19. Sven VerdoolaegeJul 15, 2007
  20. Eran TromerAug 3, 2007
  21. Sven VerdoolaegeAug 5, 2007
  22. Eran TromerAug 6, 2007

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.