From: Elijah Newren Date: Mon, 02 Aug 2010 04:37:02 GMT Subject: Re: [PATCH 09/16] subtree: rewrite incoming commits Message-ID: In-Reply-To: <1280593105-22015-10-git-send-email-pclouds@gmail.com> Hi, 2010/7/31 Nguyễn Thái Ngọc Duy : > This adds the main function, subtree_import(), which is intended to be > used by "git clone". > > Because subtree packs are not complete. They are barely usable. Git > client will cry out missing objects here and there... Theortically, > client code could be adapted to only look for objects within > subtree. That was painful to try. It may have been painful, but personally I think it's still the right way to do it. Of course, that's a pretty easy thing for me to say, since you're pretty far ahead of me and I haven't felt your pain yet. Maybe I'll change my mind after trying it for a while, but I'm not convinced just yet. > +/* > + * Take sha1 of a tree, rewrite it to only return the prefix and return > + * the newsha1. > + * > + * If if is zero, write to object store. If fd is greater than zero, > + * it's a pack file handle. Should the second word of the second paragraph be 'fd' rather than another 'if'? > +                       if (slash && slash[1]) /* trailing slash does not count */ > +                               narrow_tree(entry.sha1, newtree_sha1, prefix+subtree_len+1, fd); > +                       else > +                               memcpy(newtree_sha1, entry.sha1, 20); > + > +                       strbuf_addf(&buffer, "%o %.*s%c", entry.mode, strlen(entry.path), entry.path, '\0'); My compiler complains that you didn't typecast the return value from strlen to an int.