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 7, 2007, 03:24 UTC
Message-ID
<46B7E5FE.7050006@tromer.org>
In-Reply-To
<20070806190344.GF999MdfPADPa@greensroom.kotnet.org>
On 2007-08-06 15:03, Sven Verdoolaege wrote:
> I don't see the difference.  If you forgot you changed something
> (be it a submodule or a file) you will commit something you
> didn't plan to commit.
...
Show 5 quoted lines
>     bash-3.00$ git checkout master && echo "test" > b && git commit -a -m 'change b'
>     M       c
>     Switched to branch "master"
>     Created commit 657c5b1: change b
>      2 files changed, 2 insertions(+), 0 deletions(-)

Yes, you're right. (When I tried this, checkout complained about the dirty working tree because a *merge* was needed.)

So let's try to explicitly reset the index and work tree:

$ git reset --hard master $ vi foo $ git commit -a -m 'fixed typos'

Oops, still a corrupt commit.
Show 9 quoted lines
>>>> Another approach is for pull, checkout etc. to automatically update the
>>>> submodule' head ref, but no more.
>>> Then everything, including "git submodule update", would assume
>>> that the submodule is up-to-date.
>> With that approach, "git submodule update" would fetch the submodule's
>> head commit (which could be missing), and then check it against the
>> submodule's index (and maybe its work tree).
> And how is anyone supposed to figure out what HEAD the submodule's
> index and working tree correspond to?

What HEAD corresponds to any other dirty index or dirty working tree? It's irrelevant and may not exist. You just have some random dirty state.

If it's the yet-to-exist submodule merging you're worried about, the submodule's old head can be saved in ORIG_HEAD or some such during the supermodule checkout.

> I can only hope that "git submodule update" would never blindly assume
> that the submodule is clean and so the user would have to manually
> sync the HEAD and the working tree.

Why would it assume that? In this approach, and ignoring submodule merging for now, "git submodule update" should mean roughly "cd submodule && git fetch HEAD && git reset --hard HEAD". After all, this is really the only way to end up with the prescribed commit sha1.

I agree that for safety it makes sense to warn or abort if the index doesn't match ORIG_HEAD (saved by the supermodule checkout) or if the index doesn't match the work tree.

  Eran
Previous: Sven VerdoolaegeNext: Sven Verdoolaege
Message 13 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.