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

Re: [PATCH] unpack-trees.c: assume submodules are clean during check-out

From
ETEran Tromer <git2eran@tromer.org>
Date
Aug 4, 2007, 16:03 UTC
Message-ID
<46B4A350.9060806@tromer.org>
In-Reply-To
<7v643vj316.fsf@assigned-by-dhcp.cox.net>
On 2007-08-04 01:13, Junio C Hamano wrote:
Show 10 quoted lines
> Let me understand the problem first.  If your first checkout
> does not check out the submodule, switching between revisions
> that has different commit of the submodule there would not fail,
> but once you checkout the submodule, switching without updating
> the submodule would be Ok (because by design updating the
> submodule is optional) but then further switching out of that
> state will fail because submodule in the supermodule tree and
> checked-out submodule repository are now out of sync.  Is that
> the problem?
> 
[snip]
Show 18 quoted lines
> Where does the "No you are not up-to-date, I wouldn't let you
> switch" come from?  Is that verify_uptodate() called from
> merged_entry() called from twoway_merge()?  I think the right
> approach to deal with this is to teach verify_uptodate() about
> the policy.  The function is about "make sure the filesystem
> entity that corresponds to this cache entry is up to date, lest
> we lose the local modifications".  As we explicitly allow
> submodule checkout to drift from the supermodule index entry,
> the check should say "Ok, for submodules, not matching is the
> norm" for now.  Later when we have the ability to mark "I care
> about this submodule to be always in sync with the superproject"
> (thereby implementing automatic recursive checkout and perhaps
> diff, among other things), we should check if the submodule in
> question is marked as such and perform the current test.
> 
> How about doing something like this instead?
> 
>  unpack-trees.c |    9 +++++++++

Works here: it silences the check and allows switching branches. Still, leaving the working tree dirty can inadvertently affect subsequent commits. Consider the most ordinary of sequences:

$ git checkout experimental-death-ray $ git submodules update (return a week later, woozy from the vacation.) $ git checkout master (hack hack hack) $ git commit -a -m "fixed typos" $ git push (Oops. You've just accidentally committed the wrong submodule heads.)

So to safely make new commits you must remember to always run "git submodule update", or forgo use of "git commit -a", whenever submodules might be involved.

I guess you can hack around this by excluding submodules from "commit -a" and (for scripts) "ls-files -m" too...

Another approach is for pull, checkout etc. to automatically update the submodule' head ref, but no more. In this case the supermodule always sees a consistent state with traditional semantics, but the *submodule* ends up with a dirty working tree and a head referring to a possibly-missing commit; "git submodule update" would need to clean that up.

  Eran
Previous: Sven VerdoolaegeNext: Junio C Hamano
Message 8 of 16 in “unpack-trees.c: assume submodules are clean during check-out”
  1. unpack-trees.c: assume submodules are clean during check-outSven Verdoolaege, Jul 17, 2007
  2. Junio C HamanoJul 18, 2007
  3. Sven VerdoolaegeAug 1, 2007
  4. Junio C HamanoAug 4, 2007
  5. Lars HjemliAug 4, 2007
  6. Junio C HamanoAug 5, 2007
  7. Sven VerdoolaegeAug 5, 2007
  8. Eran TromerAug 4, 2007
  9. Junio C HamanoAug 5, 2007
  10. Sven VerdoolaegeAug 5, 2007
  11. Eran TromerAug 6, 2007
  12. Sven VerdoolaegeAug 6, 2007
  13. Eran TromerAug 7, 2007
  14. Sven VerdoolaegeAug 7, 2007
  15. Eran TromerAug 8, 2007
  16. Sven VerdoolaegeAug 8, 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.