On Wed, 18 Jul 2007, Linus Torvalds wrote:
+ if (!S_ISDIR(st->st_mode))
+ return -1;
+ ce->ce_mode = htonl(S_IFDIR);
+ pretend_sha1_file(NULL, 0, OBJ_TREE, ce->sha1);
Oh, one word of warning: that whole "pretend_sha1_file()" thing won't
create the object itself, and when I did the limited testing that I did, I
actually made sure had a magic zero-sized tree object in my object
directory.
If you don't, some things will complain, because they end up getting a
SHA1 that they cannot look up, becasue *they* didn't create that pretend
entry.
I didn't know which way I wanted to go with that thing. I was kind of
thinking that maybe we would just have the zero-sized OBJ_BLOB and
OBJ_TREE objects as special magical things, and have all git programs just
do that "pretend" at the beginning.
But that kind of thing is probably just a totally unnecessary special
case, and instead, that "pretend_sha1_file()" should have just been a
write_sha1_file(NULL, 0, "tree", ce->sha1);
instead.
Anyway, if there are issues with not finding an object called
4b825dc642cb6eb9a060e54bf8d69288fbee4904, then that's the empty tree
object, and that pretend thing was the cause.
(The git repo itself has the empty tree as an object in it, because one of
the commits has that - probably as a result of a bug, but there you have
it)
Linus