Does a commit object always have exactly one tree object?
I can't think of a scenario where it wouldn't be the case but I also can't see any documentation that explicitly states it.
CodePudding user response:
Does a commit object always have exactly one [top-level] tree object?
Yes.
I can't think of a scenario where it wouldn't be the case but I also can't see any documentation that explicitly states it.
It's part of the design: without it, git rev-parse commit^{tree}
would not have an unambiguous result.
One can envision a system related to Git in which commits can store multiple trees,1 but a number of design issues would need to be resolved first.
1I've thought about this in several contexts, including the "submodules are wrong, subtrees are better but need better support" one. I have not resolved everything.