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

Re: Calculating tree nodes

From
Shawn O. Pearce <spearce@spearce.org>
Date
Sep 4, 2007, 02:51 UTC
Message-ID
<20070904025153.GS18160@spearce.org>
In-Reply-To
<9e4733910709031913q278cb9dbp441756afb28607c6@mail.gmail.com>
Jon Smirl <jonsmirl@gmail.com> wrote:
Show 6 quoted lines
> When I change a file it creates a new object with a new SHA. This new
> SHA causes the tree node pointing to it to change. Changing the tree
> node forces its parent to change and so on. Of course git batches all
> of the changes together into a commit so that this ripple effect
> doesn't happen for every file. But every commit causes a new root tree
> node to be created, right?

Only if at least one file (or tree) differed. This may not be the case if you do a merge with the ours merge strategy, but these are very rare. So you can pretty much just say that yes, every commit causes a new root tree to be created.

Usually the smallest number of objects created per commit is 3:
  - the new commit
  - the new root tree
  - the new blob for a file in the root directory

The number increases as more files are modified or if they are in subdirectories of the root.

-- 
Shawn.
Previous: Jon SmirlNext: Jon Smirl
Message 2 of 27 in “Calculating tree nodes”
  1. Jon SmirlSep 4, 2007
  2. Shawn O. PearceSep 4, 2007
  3. Jon SmirlSep 4, 2007
  4. Johannes SchindelinSep 4, 2007
  5. Jon SmirlSep 4, 2007
  6. Martin LanghoffSep 4, 2007
  7. Jon SmirlSep 4, 2007
  8. Andreas EricssonSep 4, 2007
  9. Johannes SchindelinSep 4, 2007
  10. Jon SmirlSep 4, 2007
  11. Johannes SchindelinSep 4, 2007
  12. Andreas EricssonSep 4, 2007
  13. Martin LanghoffSep 4, 2007
  14. Junio C HamanoSep 4, 2007
  15. Jon SmirlSep 4, 2007
  16. David TweedSep 4, 2007
  17. Jon SmirlSep 4, 2007
  18. Andreas EricssonSep 4, 2007
  19. Shawn O. PearceSep 4, 2007
  20. Jon SmirlSep 4, 2007
  21. Andreas EricssonSep 4, 2007
  22. David TweedSep 4, 2007
  23. Shawn O. PearceSep 4, 2007
  24. Junio C HamanoSep 4, 2007
  25. Shawn O. PearceSep 6, 2007
  26. Junio C HamanoSep 6, 2007
  27. Daniel HulmeSep 4, 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.