Re: parsecvs tool now creates git repositories
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:42:23
Keith Packard [off-list ref] writes:
I've just changed parsecvs to generate blobs for every revision in each ,v file right after they're read in; putting the necessary code right into parsecvs should be reasonably straightforward; we don't need the multi-patch logic as we do want to compute each intermediate version of the file.
If you want to go really fast without extra fork, are writing it
in C, and have the data for blob in core, you could link with
libgit.a and call write_sha1_file() yourself:
unsigned char sha1[20];
void *buf;
unsigned long len;
write_sha1_file(buf, len, "blob", sha1);
instead of forking "hash-object -w". You feed your blob data
in buf, with its length in len, and you will get the blob object
name back in sha1[]. buf is owned by you and after
write_sha1_file() returns it is safe for you to scribble over it
or free() it. sha1[] stores binary object name (20 bytes, not
40-byte hexadecimal), and you can use the helper function
sha1_to_hex() if you need a hex representation:
char *sha1_to_hex(sha1)
which returns a pointer to a static buffer that is valid until
next call to sha1_to_hex(), so you need to strdup it if you want
to retain it.