Re: Calculating tree nodes
From: Shawn O. Pearce <hidden>
Date: 2016-06-15 22:43:33
Jon Smirl [off-list ref] wrote:
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.