On Tue, Nov 15, 2016 at 12:01:35PM -0800, Junio C Hamano wrote: > Jeff King <peff@xxxxxxxx> writes: > > > I suspect the issue is that read-tree populates the cache-tree index > > extension, and then write-tree omits the object write before it even > > gets to write_sha1_file(). The solution is that it should probably be > > calling one of the freshen() functions (possibly just replacing > > has_sha1_file() with check_and_freshen(), but I haven't looked). > > I think the final writing always happens via write_sha1_file(), but > an earlier cache-tree update that says "if we have a tree object > already, then use it, otherwise even though we know the object name > for this subtree, do not record it in the cache-tree" codepath may > decide to record the subtree's sha1 without refreshing the referent. > > A fix may look like this. Yeah, that's along the lines I was expecting, though I'm not familiar enough with cache-tree to say whether it's sufficient. I notice there is a return very early on in update_one() when has_sha1_file() matches, and it seems like that would trigger in some interesting cases, too. -Peff