Re: [PATCH 2/3] merge-recursive: make empty tree a known object
From: Linus Torvalds <torvalds@osdl.org>
Date: 2016-08-11 20:04:46
On Sun, 10 Dec 2006, Johannes Schindelin wrote:
To use it in diff_tree_sha1(), a tree has to be hashed in the global object collection. This actually moves the empty tree (if it is needed) into the global object hash.
I think you should do this more generically. If we create this kind of "default fake object" that we know about whether the object _really_ exists or not (and I agree it makes sense for the empty tree), we should probably use it for "diff_root_tree_sha1()" too, rather than the special case we have now. In other words, right now we have that very special "diff_root_tree_sha1()" function, but if you create a generic fake "empty tree" SHA1 that git knows about implicitly, we could entirely replace it with just using diff_tree_sha1(EMPTY_TREE_SHA1, tree, base, opt); instead, and get rid of that special case code (which is efficient, but we don't really _need_ the efficiency). So you could make "read_sha1_file()" just have a special case for known objects at the end. If the pack entry fails, the loose file case fails, then rather than returning NULL at the end, you could have a list of known fixed objects.. Hmm?