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

Re: naive question

From
Linus Torvalds <torvalds@osdl.org>
Date
Apr 19, 2005, 18:27 UTC
Message-ID
<Pine.LNX.4.58.0504191117570.19286@ppc970.osdl.org>
In-Reply-To
<Pine.LNX.4.58.0504191036560.19286@ppc970.osdl.org>
On Tue, 19 Apr 2005, Linus Torvalds wrote:
Show 6 quoted lines
> 
> The real expense right now of a merge is that we always forget all the
> stat information when we do a merge (since it does a read-tree). I have a
> cunning way to fix that, though, which is to make "read-tree -m" read in
> the old index state like it used to, and then at the end just throw it
> away except for the stat information.

Ok, done. That was really the plan all along, it just got dropped in the excitement of trying to get the dang thing to _work_ in the first place ;)

The current version only does
	read-tree -m <orig> <branch1> <branch2>

which now reads the old stat cache information, and then applies that to the end result of any trivial merges in case the merge result matches the old file stats. It really boils down to this littel gem;

            /*
             * See if we can re-use the old CE directly?
             * That way we get the uptodate stat info.
             */
            if (path_matches(result, old) && same(result, old))
                    *result = *old;
and it seems to work fine.
HOWEVER, I'll also make it do the same for a "single-tree merge":
	read-tree -m <newtree>

so that you can basically say "read a new tree, and merge the stat information from the current cache". That means that if you do a "read-tree -m <newtree>" followed by a "checkout-cache -f -a", the checkout-cache only checks out the stuff that really changed.

You'll still need to do an "update-cache --refresh" for the actual new stuff. We could make "checkout-cache" update the cache too, but I really do prefer a "checkout-cache only reads the index, never changes it" world-view. It's nice to be able to have a read-only git tree.

Final note: just doing a plain "read-tree <newtree>" will still throw all the stat info away, and you'll have to refresh it all...

		Linus
Previous: Linus Torvalds
Message 6 of 6 in “naive question”
  1. Paul MackerrasApr 19, 2005
  2. David WoodhouseApr 19, 2005
  3. Ingo MolnarApr 19, 2005
  4. Petr BaudisApr 19, 2005
  5. Linus TorvaldsApr 19, 2005
  6. Linus TorvaldsApr 19, 2005

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.