On Wed, 12 Oct 2005 13:02:36 +0200 (CEST) Johannes Schindelin wrote: > Add the option '--create-index' to git-unpack-objects, which makes it > create an index file instead of expanding its contents. While at it, > document the dry-run option '-n', and optionally take a pack file instead > of stdin. > @@ -104,7 +119,15 @@ static void added_object(unsigned char * > static void write_object(void *buf, unsigned long size, const char *type) > { > unsigned char sha1[20]; > - if (write_sha1_file(buf, size, type, sha1) < 0) > + if (create_index) { > + char header[100]; > + SHA_CTX c; > + > + SHA1_Init(&c); > + SHA1_Update(&c, header, 1+sprintf(header, "%s %lu", type, size)); > + SHA1_Update(&c, buf, size); > + SHA1_Final(current_sha1, &c); > + } else if (write_sha1_file(buf, size, type, sha1) < 0) > die("failed to write object"); Sorry, but this cannot work. git-unpack-objects does a streaming unpack, and it needs to be able to read back the objects it has written out previously (in case a delta later in the stream references some older object). Saving unpacked objects in memory would obviously be unacceptable. However, if you need to create a pack index, you obviously have a pack file with random access ability, and in this case it is possible to build the index efficiently (in two passes over the pack file) without storing unpacked objects in the filesystem. I made a separate utility to do this; will send a patch in some minutes. - To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
This archive was generated by hypermail 2.1.8 : 2005-10-12 23:35:35 EST