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 8, 2007, 01:41 UTC
Message-ID
<46B91F4E.8050008@tromer.org>
In-Reply-To
<20070807085149.GH999MdfPADPa@greensroom.kotnet.org>
On 2007-08-07 04:51, Sven Verdoolaege wrote:
> Surely this is a lot worse than occasionally committing something you
> didn't plan to commit, and only if you are performing a known "dangerous"
> operation.
> 

Are you saying that $ git reset --hard HEAD && vi foo && git commit -a is a "known dangerous" operation that can record corrupted content even though you didn't touch it? This is very bad news indeed! I don't see any such warnings in the documentation.

So, when I'm sure all the edits I did in the work tree are fine, how *do* I safely make a commit without manually inspecting the changed files list, or manually listing the changed files for "git add", or manually running "git submodule update", or manually checking whether there happens to be some submodules in this project, some other such cumbersome measure?

> You may have done several supermodule checkouts since you last changed
> the submodule.

True, that approach won't work. I can imagine some logic to conditionally update ORIG_HEAD, but it gets messy and fragile. Looks like brokenness is just inevitable when you let the state get stale and then merrily read it out as if it's fresh.

So.... Maybe we can tackle this head-on? Let index entries be explicitly marked as "adrift", meaning we just don't touch the work tree for these entries -- neither reads nor writes. It's used when the piece of content, say a submodule, is allowed to drift arbitrarily in the work tree in a way that doesn't represent meaningful edits that should be reflected in commits, diffs, etc.

For example:
- "git checkout" sets the "adrift" flag on all (modified?) submodules
- "git submodule update" undrifts ("moores?") the submodules
- "git commit -a" skips files that are adrift, and likewise "git add .",
  "git diff" etc. (perhaps with some warning?)
- "git add <path>" undrifts <path> and proceeds as usual
- "git status" reports drifting files as such and doesn't bother to
  check them in the work tree
- When merging into the work tree, drifting files are left as such

And why stop at submodules? If there's a large blob you don't want to check out, just "git drift <path>" it. To set whole *directories* adrift, we can piggybacking on the empty-directory support (i.e., add a directory entry to the index and set it adrift). So this could be the basis of partial-checkout support.

Does this sound reasonable?
  Eran
Previous: Sven VerdoolaegeNext: Sven Verdoolaege
Message 15 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.